35 .encode_op = VK_VIDEO_CODEC_OPERATION_ENCODE_AV1_BIT_KHR,
37 .extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_EXTENSION_NAME,
38 .specVersion = VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_SPEC_VERSION,
88 VkVideoEncodeAV1CapabilitiesKHR
caps;
109 VkVideoEncodeRateControlInfoKHR *rc_info,
110 VkVideoEncodeRateControlLayerInfoKHR *rc_layer)
118 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_GOP_REMAINING_FRAME_INFO_KHR,
119 .useGopRemainingFrames = 0,
120 .gopRemainingIntra = 0,
121 .gopRemainingPredictive = 0,
122 .gopRemainingBipredictive = 0,
125 ap->
vkrc_info = (VkVideoEncodeAV1RateControlInfoKHR) {
126 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_RATE_CONTROL_INFO_KHR,
127 .flags = VK_VIDEO_ENCODE_AV1_RATE_CONTROL_REFERENCE_PATTERN_FLAT_BIT_KHR |
128 VK_VIDEO_ENCODE_AV1_RATE_CONTROL_REGULAR_GOP_BIT_KHR,
129 .gopFrameCount =
ctx->base.gop_size,
130 .keyFramePeriod =
ctx->base.gop_size,
131 .consecutiveBipredictiveFrameCount =
FFMAX(
ctx->base.b_per_p - 1, 0),
132 .temporalLayerCount = 0,
136 if (rc_info->rateControlMode > VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR) {
141 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_RATE_CONTROL_LAYER_INFO_KHR,
143 .useMinQIndex = avctx->
qmin > 0,
144 .minQIndex.intraQIndex = avctx->
qmin > 0 ? avctx->
qmin : 0,
145 .minQIndex.predictiveQIndex = avctx->
qmin > 0 ? avctx->
qmin : 0,
146 .minQIndex.bipredictiveQIndex = avctx->
qmin > 0 ? avctx->
qmin : 0,
148 .useMaxQIndex = avctx->
qmax > 0,
149 .maxQIndex.intraQIndex = avctx->
qmax > 0 ? avctx->
qmax : 0,
150 .maxQIndex.predictiveQIndex = avctx->
qmax > 0 ? avctx->
qmax : 0,
151 .maxQIndex.bipredictiveQIndex = avctx->
qmax > 0 ? avctx->
qmax : 0,
153 .useMaxFrameSize = 0,
162static int set_name_slot(
int slot,
int *slot_indices, uint32_t allowed_idx,
int group)
168 if ((slot_indices[
i] == -1) && (allowed_idx & (1 <<
i))) {
169 slot_indices[
i] = slot;
178 VkVideoEncodeInfoKHR *encode_info)
187 VkVideoReferenceSlotInfoKHR *ref_slot;
189 uint32_t ref_name_mask = 0x0;
190 int name_slots[STD_VIDEO_AV1_REFS_PER_FRAME];
193 StdVideoAV1Segmentation *segmentation = &ap->
segmentation;
195 StdVideoAV1Quantization *quantization = &ap->
quantization;
196 StdVideoAV1CDEF *cdef = &ap->
cdef;
200 static const int8_t default_loop_filter_ref_deltas[STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME] =
201 { 1, 0, 0, 0, -1, 0, -1, -1 };
203 VkVideoEncodeAV1PredictionModeKHR pred_mode;
204 VkVideoEncodeAV1RateControlGroupKHR rc_group;
205 int lr_unit_shift = 0;
208 ap->
ext_header = (StdVideoEncodeAV1ExtensionHeader) {
214 .flags = (StdVideoAV1TileInfoFlags) {
219 .context_update_tile_id = 0,
220 .tile_size_bytes_minus_1 = 0,
223 for (
int i = 0;
i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME;
i++) {
224 global_motion->GmType[
i] = 0;
225 for (
int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) {
226 global_motion->gm_params[
i][j] = 0;
230 for (
int i = 0;
i < STD_VIDEO_AV1_REFS_PER_FRAME;
i++)
233 *loop_restoration = (StdVideoAV1LoopRestoration) {
234 .FrameRestorationType[0] = STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE,
235 .FrameRestorationType[1] = STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE,
236 .FrameRestorationType[2] = STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE,
237 .LoopRestorationSize[0] = 1 + lr_unit_shift,
238 .LoopRestorationSize[1] = 1 + lr_unit_shift - lr_uv_shift,
239 .LoopRestorationSize[2] = 1 + lr_unit_shift - lr_uv_shift,
242 *cdef = (StdVideoAV1CDEF) {
243 .cdef_damping_minus_3 = 0,
247 for (
int i = 0;
i < STD_VIDEO_AV1_MAX_SEGMENTS;
i++) {
248 segmentation->FeatureEnabled[
i] = 0x0;
249 for (
int j = 0; j < STD_VIDEO_AV1_SEG_LVL_MAX; j++) {
250 segmentation->FeatureEnabled[
i] |= 0x0;
251 segmentation->FeatureData[
i][j] = 0;
256 .flags = (StdVideoAV1LoopFilterFlags) {
257 .loop_filter_delta_enabled = 0,
258 .loop_filter_delta_update = 0,
260 .loop_filter_level = { 0 },
261 .loop_filter_sharpness = 0,
262 .update_ref_delta = 0,
263 .loop_filter_ref_deltas = { 0 },
264 .update_mode_delta = 0,
265 .loop_filter_mode_deltas = { 0 },
268 memcpy(
loop_filter->loop_filter_ref_deltas, default_loop_filter_ref_deltas,
269 STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME *
sizeof(int8_t));
271 *quantization = (StdVideoAV1Quantization) {
272 .flags = (StdVideoAV1QuantizationFlags) {
288 ref_slot = (VkVideoReferenceSlotInfoKHR *)encode_info->pSetupReferenceSlot;
290 .flags = (StdVideoEncodeAV1PictureInfoFlags) {
294 .disable_cdf_update = 0,
296 .render_and_frame_size_different = 0,
297 .allow_screen_content_tools = 0,
298 .is_filter_switchable = 0,
299 .force_integer_mv = 0,
300 .frame_size_override_flag = 0,
301 .buffer_removal_time_present_flag = 0,
303 .frame_refs_short_signaling = 0,
304 .allow_high_precision_mv = 0,
305 .is_motion_mode_switchable = 0,
306 .use_ref_frame_mvs = 0,
307 .disable_frame_end_update_cdf = 0,
308 .allow_warped_motion = 0,
310 .skip_mode_present = 0,
311 .delta_q_present = 0,
312 .delta_lf_present = 0,
314 .segmentation_enabled = 0,
315 .segmentation_update_map = 0,
316 .segmentation_temporal_update = 0,
317 .segmentation_update_data = 0,
325 .frame_presentation_time = 0,
326 .current_frame_id = ref_slot->slotIndex,
328 .primary_ref_frame = 0,
329 .refresh_frame_flags = 0x0,
333 .interpolation_filter = 0,
334 .TxMode = STD_VIDEO_AV1_TX_MODE_SELECT,
337 .ref_order_hint = { 0 },
338 .ref_frame_idx = { 0 },
340 .delta_frame_id_minus_1 = { 0 },
343 .pQuantization = quantization,
344 .pSegmentation = segmentation,
347 .pLoopRestoration = loop_restoration,
348 .pGlobalMotion = global_motion,
350 .pBufferRemovalTimes =
NULL,
357 ap->
av1pic_info.frame_type = STD_VIDEO_AV1_FRAME_TYPE_KEY;
359 ap->
av1pic_info.primary_ref_frame = STD_VIDEO_AV1_PRIMARY_REF_NONE;
360 quantization->base_q_idx = enc->
q_idx_idr;
363 pred_mode = VK_VIDEO_ENCODE_AV1_PREDICTION_MODE_INTRA_ONLY_KHR;
364 rc_group = VK_VIDEO_ENCODE_AV1_RATE_CONTROL_GROUP_INTRA_KHR;
368 ap_ref =
ref->codec_priv;
370 ap->
av1pic_info.frame_type = STD_VIDEO_AV1_FRAME_TYPE_INTER;
371 quantization->base_q_idx = enc->
q_idx_p;
383 rc_group = VK_VIDEO_ENCODE_AV1_RATE_CONTROL_GROUP_PREDICTIVE_KHR;
384 pred_mode = VK_VIDEO_ENCODE_AV1_PREDICTION_MODE_SINGLE_REFERENCE_KHR;
385 ref_name_mask = enc->
caps.singleReferenceNameMask;
393 ((enc->
caps.maxSingleReferenceCount > 1) ||
394 (enc->
caps.maxUnidirectionalCompoundReferenceCount > 0))) {
395 if (enc->
caps.maxUnidirectionalCompoundReferenceCount) {
396 pred_mode = VK_VIDEO_ENCODE_AV1_PREDICTION_MODE_UNIDIRECTIONAL_COMPOUND_KHR;
397 ref_name_mask = enc->
caps.unidirectionalCompoundReferenceNameMask;
400 ap_ref =
ref->codec_priv;
408 ap->
av1pic_info.frame_type = STD_VIDEO_AV1_FRAME_TYPE_INTER;
409 quantization->base_q_idx = enc->
q_idx_b;
412 rc_group = VK_VIDEO_ENCODE_AV1_RATE_CONTROL_GROUP_BIPREDICTIVE_KHR;
413 pred_mode = VK_VIDEO_ENCODE_AV1_PREDICTION_MODE_BIDIRECTIONAL_COMPOUND_KHR;
414 ref_name_mask = enc->
caps.bidirectionalCompoundReferenceNameMask;
425 ap_ref =
ref->codec_priv;
434 ap_ref =
ref->codec_priv;
446 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_PICTURE_INFO_KHR,
448 .predictionMode = pred_mode,
449 .rateControlGroup = rc_group,
450 .constantQIndex = quantization->base_q_idx,
453 .primaryReferenceCdfOnly = 0,
454 .generateObuExtensionHeader = 0,
458 if (
ctx->opts.rc_mode != VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR)
465 ref_slot = (VkVideoReferenceSlotInfoKHR *)encode_info->pSetupReferenceSlot;
468 ap->
av1dpb_info = (StdVideoEncodeAV1ReferenceInfo) {
469 .flags = (StdVideoEncodeAV1ReferenceInfoFlags) {
470 .disable_frame_end_update_cdf = 0,
471 .segmentation_enabled = 0,
474 .RefFrameId = ref_slot->slotIndex,
482 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_DPB_SLOT_INFO_KHR,
499 const int chroma_den = 1 << 16;
500 const int max_luma_den = 1 << 8;
501 const int min_luma_den = 1 << 14;
503 memset(obu, 0,
sizeof(*obu));
507 for (
int i = 0;
i < 3;
i++) {
542 memset(obu, 0,
sizeof(*obu));
560 memset(obu, 0,
sizeof(*obu));
578 memset(obu, 0,
sizeof(*obu));
595 VkVideoProfileInfoKHR *
profile,
void *pnext)
603 VkVideoEncodeAV1CapabilitiesKHR av1_caps = {
604 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_CAPABILITIES_KHR,
606 VkVideoEncodeCapabilitiesKHR enc_caps = {
607 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR,
610 VkVideoCapabilitiesKHR caps = {
611 .sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR,
617 static const int known_profiles[] = {
632 enc->
profile = (VkVideoEncodeAV1ProfileInfoKHR) {
633 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_PROFILE_INFO_KHR,
644 for (
int i = 0;
i < nb_profiles;
i++) {
646 ret = vk->GetPhysicalDeviceVideoCapabilitiesKHR(
s->hwctx->phys_dev,
649 if (
ret == VK_SUCCESS) {
652 last_supported = known_profiles[
i];
664 avctx->
profile = last_supported;
683 "must have initial buffer size (%d) <= "
684 "buffer size (%"PRId64
").\n",
693 if (enc->
common.
opts.
rc_mode == VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR) {
695 enc->
caps.minQIndex, enc->
caps.maxQIndex);
751 "any normal level, using level 7.3 by default.\n");
769 .enable_order_hint = 1,
771 .use_128x128_superblock = !!(enc->
caps.superblockSizes & VK_VIDEO_ENCODE_AV1_SUPERBLOCK_SIZE_128_BIT_KHR),
773 .high_bitdepth =
desc->comp[0].depth > 8,
775 .transfer_characteristics = avctx->
color_trc,
780 .subsampling_x =
desc->log2_chroma_w,
781 .subsampling_y =
desc->log2_chroma_h,
794 .operating_points_cnt_minus_1 = 1 - 1,
817 StdVideoAV1SequenceHeader *seq_hdr = &vk_units->
seq_hdr;
821 StdVideoEncodeAV1OperatingPointInfo *operating_points = vk_units->
operating_points;
824 .flags = (StdVideoAV1TimingInfoFlags) {
833 .flags = (StdVideoAV1ColorConfigFlags) {
847 *seq_hdr = (StdVideoAV1SequenceHeader) {
848 .flags = (StdVideoAV1SequenceHeaderFlags) {
884 operating_points[
i] = (StdVideoEncodeAV1OperatingPointInfo) {
885 .flags = (StdVideoEncodeAV1OperatingPointInfoFlags) {
914 VkVideoEncodeAV1SessionParametersCreateInfoKHR av1_params;
925 if (
ctx->session_params)
926 vk->DestroyVideoSessionParametersKHR(
s->hwctx->act_dev,
930 av1_params = (VkVideoEncodeAV1SessionParametersCreateInfoKHR) {
931 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
932 .pStdSequenceHeader = &vk_units.
seq_hdr,
979 ff_cbs_fragment_free(&obu);
994 VkVideoEncodeSessionParametersGetInfoKHR params_info;
995 VkVideoEncodeSessionParametersFeedbackInfoKHR params_feedback;
998 size_t data_size = 0;
1013 params_info = (VkVideoEncodeSessionParametersGetInfoKHR) {
1014 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_GET_INFO_KHR,
1015 .videoSessionParameters =
ctx->session_params,
1017 params_feedback = (VkVideoEncodeSessionParametersFeedbackInfoKHR) {
1018 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_FEEDBACK_INFO_KHR,
1021 ret = vk->GetEncodedVideoSessionParametersKHR(
s->hwctx->act_dev, ¶ms_info,
1024 if (
ret == VK_INCOMPLETE ||
1025 (
ret == VK_SUCCESS) && (data_size > 0)) {
1030 av_log(avctx,
AV_LOG_ERROR,
"Unable to get feedback for AV1 sequence header = %zu\n",
1035 ret = vk->GetEncodedVideoSessionParametersKHR(
s->hwctx->act_dev, ¶ms_info,
1038 if (
ret != VK_SUCCESS) {
1045 params_feedback.hasOverrides);
1047 params_feedback.hasOverrides = 1;
1051 if (!params_feedback.hasOverrides)
1069 uint8_t
type,
void *obu_unit)
1073 err = ff_cbs_insert_unit_content(au, -1,
1077 "type = %d.\n",
type);
1085 uint8_t *
data,
size_t *data_len,
1091 ret = ff_cbs_write_fragment_data(enc->
cbs, obu);
1105 uint8_t *
data,
size_t *data_len)
1119 ff_cbs_fragment_reset(obu);
1125 uint8_t *
data,
size_t *data_len)
1139 err = ff_cbs_write_fragment_data(enc->
cbs, obu);
1143 ff_cbs_fragment_reset(obu);
1181 ff_cbs_fragment_reset(obu);
1186 uint8_t *
data,
size_t *data_len)
1202 .payload_size = padding,
1211 ff_cbs_fragment_reset(obu);
1221 .filler_header_size = 4,
1243 enc->
caps = (VkVideoEncodeAV1CapabilitiesKHR) {
1244 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_CAPABILITIES_KHR,
1247 enc->
quality_props = (VkVideoEncodeAV1QualityLevelPropertiesKHR) {
1248 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_QUALITY_LEVEL_PROPERTIES_KHR,
1260 !!(enc->
caps.flags & VK_VIDEO_ENCODE_AV1_CAPABILITY_PER_RATE_CONTROL_GROUP_MIN_MAX_Q_INDEX_BIT_KHR));
1262 !!(enc->
caps.flags & VK_VIDEO_ENCODE_AV1_CAPABILITY_GENERATE_OBU_EXTENSION_HEADER_BIT_KHR));
1264 !!(enc->
caps.flags & VK_VIDEO_ENCODE_AV1_CAPABILITY_PRIMARY_REFERENCE_CDF_ONLY_BIT_KHR));
1266 !!(enc->
caps.flags & VK_VIDEO_ENCODE_AV1_CAPABILITY_FRAME_SIZE_OVERRIDE_BIT_KHR));
1268 !!(enc->
caps.flags & VK_VIDEO_ENCODE_AV1_CAPABILITY_MOTION_VECTOR_SCALING_BIT_KHR));
1271 !!(enc->
caps.superblockSizes & VK_VIDEO_ENCODE_AV1_SUPERBLOCK_SIZE_64_BIT_KHR));
1273 !!(enc->
caps.superblockSizes & VK_VIDEO_ENCODE_AV1_SUPERBLOCK_SIZE_128_BIT_KHR));
1275 enc->
caps.maxSingleReferenceCount);
1277 enc->
caps.singleReferenceNameMask);
1279 enc->
caps.maxUnidirectionalCompoundReferenceCount);
1281 enc->
caps.maxUnidirectionalCompoundGroup1ReferenceCount);
1283 enc->
caps.unidirectionalCompoundReferenceNameMask);
1285 enc->
caps.maxBidirectionalCompoundReferenceCount);
1287 enc->
caps.maxBidirectionalCompoundGroup1ReferenceCount);
1289 enc->
caps.maxBidirectionalCompoundGroup2ReferenceCount);
1291 enc->
caps.bidirectionalCompoundReferenceNameMask);
1293 enc->
caps.maxTemporalLayerCount);
1295 enc->
caps.maxSpatialLayerCount);
1297 enc->
caps.maxOperatingPoints);
1299 enc->
caps.minQIndex, enc->
caps.maxQIndex);
1301 enc->
caps.prefersGopRemainingFrames);
1303 enc->
caps.requiresGopRemainingFrames);
1305 enc->
caps.maxLevel);
1307 enc->
caps.codedPictureAlignment.width, enc->
caps.codedPictureAlignment.height);
1309 enc->
caps.maxTiles.width, enc->
caps.maxTiles.height);
1311 enc->
caps.minTileSize.width, enc->
caps.minTileSize.height,
1312 enc->
caps.maxTileSize.width, enc->
caps.maxTileSize.height);
1320 ctx->caps.maxDpbSlots,
1321 enc->
caps.maxBidirectionalCompoundReferenceCount,
1341 size_t data_len =
sizeof(
data);
1346 "for extradata: %d.\n", err);
1374 ff_cbs_close(&enc->
cbs);
1381#define OFFSET(x) offsetof(VulkanEncodeAV1Context, x)
1382#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
1387 {
"profile",
"Set profile",
1391#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1392 { .i64 = value }, 0, 0, FLAGS, .unit = "profile"
1398 {
"tier",
"Set tier (seq_tier)",
1403 {
"level",
"Set level (level_idc)",
1407#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1408 { .i64 = value }, 0, 0, FLAGS, .unit = "level"
1419 {
LEVEL(
"42", 10) },
1420 {
LEVEL(
"43", 11) },
1421 {
LEVEL(
"50", 12) },
1422 {
LEVEL(
"51", 13) },
1423 {
LEVEL(
"52", 14) },
1424 {
LEVEL(
"53", 15) },
1425 {
LEVEL(
"60", 16) },
1426 {
LEVEL(
"61", 17) },
1427 {
LEVEL(
"62", 18) },
1428 {
LEVEL(
"63", 19) },
1429 {
LEVEL(
"70", 20) },
1430 {
LEVEL(
"71", 21) },
1431 {
LEVEL(
"72", 22) },
1432 {
LEVEL(
"73", 23) },
1452 .class_name =
"av1_vulkan",
1459 .p.name =
"av1_vulkan",
1477 .p.wrapper_name =
"vulkan",
const FFCodec ff_av1_vulkan_encoder
static AVFormatContext * ctx
const AV1LevelDescriptor * ff_av1_guess_level(int64_t bitrate, int tier, int width, int height, int tiles, int tile_cols, float fps)
Guess the level of a stream from some parameters.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int FUNC tile_info(CodedBitstreamContext *ctx, RWContext *rw, APVRawTileInfo *current, const APVRawFrameHeader *fh)
static int FUNC color_config(CodedBitstreamContext *ctx, RWContext *rw, AV1RawColorConfig *current, int seq_profile)
static int FUNC timing_info(CodedBitstreamContext *ctx, RWContext *rw, AV1RawTimingInfo *current)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_RECEIVE_PACKET_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static __device__ float fabs(float a)
#define AV_PROFILE_AV1_HIGH
#define AV_PROFILE_UNKNOWN
#define AV_PROFILE_AV1_MAIN
#define AV_PROFILE_AV1_PROFESSIONAL
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define LIBAVUTIL_VERSION_INT
static void loop_filter(const H264Context *h, H264SliceContext *sl, int start_x, int end_x)
int ff_hw_base_init_gop_structure(FFHWBaseEncodeContext *ctx, AVCodecContext *avctx, uint32_t ref_l0, uint32_t ref_l1, int flags, int prediction_pre_only)
#define HW_BASE_ENCODE_COMMON_OPTIONS
@ FF_HW_FLAG_SLICE_CONTROL
@ FF_HW_FLAG_B_PICTURE_REFERENCES
@ AV1_METADATA_TYPE_HDR_MDCV
@ AV1_METADATA_TYPE_HDR_CLL
@ AV1_OBU_SEQUENCE_HEADER
@ AV1_SELECT_SCREEN_CONTENT_TOOLS
@ AV1_MAX_OPERATING_POINTS
@ AV1_TOTAL_REFS_PER_FRAME
Memory handling functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
#define FF_ARRAY_ELEMS(a)
uint8_t matrix_coefficients
uint8_t transfer_characteristics
uint8_t separate_uv_delta_q
AV1RawFrameHeader frame_header
AV1RawSequenceHeader sequence_header
union AV1RawOBU::@016362317061177152367125047142162076164261250366 obu
uint32_t num_units_in_display_tick
uint32_t num_ticks_per_picture_minus_1
uint8_t equal_picture_interval
Describe the class of an AVClass context structure.
main external API structure.
int rc_buffer_size
decoder bitstream buffer size
float b_quant_offset
qscale offset between IP and B-frames
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
int qmin
minimum quantizer
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
int level
Encoding level descriptor.
int64_t bit_rate
the average bitrate
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
enum AVColorSpace colorspace
YUV colorspace type.
int64_t rc_max_rate
maximum bitrate
int qmax
maximum quantizer
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
float i_quant_offset
qscale offset between P and I-frames
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
Structure to hold side data for an AVFrame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Context structure for coded bitstream operations.
void * priv_data
Internal codec-specific data.
Coded bitstream fragment structure, combining one or more units.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
int nb_units
Number of units in this fragment.
size_t data_size
The number of bytes in the bitstream.
uint8_t * data
Pointer to the bitstream form of this fragment.
void * content
Pointer to the decomposed form of this unit.
CodedBitstreamUnitType type
Codec-specific type of this unit.
int nb_refs[MAX_REFERENCE_LIST_NUM]
struct FFHWBaseEncodePicture * refs[MAX_REFERENCE_LIST_NUM][MAX_PICTURE_REFERENCES]
VkVideoEncodeRateControlModeFlagBitsKHR rc_mode
FFVkEncodeCommonOptions opts
int non_independent_frame
StdVideoAV1SequenceHeader seq_hdr
StdVideoAV1TimingInfo timing_info
StdVideoEncodeAV1OperatingPointInfo operating_points[AV1_MAX_OPERATING_POINTS]
StdVideoAV1ColorConfig color_config
StdVideoEncodeAV1DecoderModelInfo decoder_model
AV1RawOBU meta_mastering_obu
FFVulkanEncodeContext common
CodedBitstreamFragment current_access_unit
CodedBitstreamContext * cbs
VkVideoEncodeAV1QualityLevelPropertiesKHR quality_props
uint8_t * padding_payload
enum UnitElems unit_elems
VkVideoEncodeAV1CapabilitiesKHR caps
VkVideoEncodeAV1ProfileInfoKHR profile
uint64_t initial_buffer_fullness
StdVideoAV1TileInfo tile_info
VkVideoEncodeAV1RateControlInfoKHR vkrc_info
StdVideoEncodeAV1ExtensionHeader ext_header
StdVideoAV1GlobalMotion global_motion
StdVideoAV1LoopFilter loop_filter
VkVideoEncodeAV1RateControlLayerInfoKHR vkrc_layer_info
StdVideoEncodeAV1PictureInfo av1pic_info
StdVideoAV1Quantization quantization
VkVideoEncodeAV1PictureInfoKHR vkav1pic_info
StdVideoAV1LoopRestoration loop_restoration
VkVideoEncodeAV1DpbSlotInfoKHR vkav1dpb_info
StdVideoEncodeAV1ReferenceInfo av1dpb_info
VkVideoEncodeAV1GopRemainingFrameInfoKHR vkrc_remaining
enum UnitElems units_needed
StdVideoAV1Segmentation segmentation
static int ref[MAX_W *MAX_W]
const AVCodecHWConfigInternal *const ff_vulkan_encode_hw_configs[]
Paperwork.
av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, const FFVulkanEncodeDescriptor *vk_desc, const FFVulkanCodec *codec, void *codec_caps, void *quality_pnext)
Initialize encoder.
av_cold void ff_vulkan_encode_uninit(FFVulkanEncodeContext *ctx)
Uninitialize encoder.
static int init_pic_rc(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeRateControlInfoKHR *rc_info, VkVideoEncodeRateControlLayerInfoKHR *rc_layer)
int ff_vulkan_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Encode.
int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, void *codec_params_pnext)
Create session parameters.
#define VULKAN_ENCODE_COMMON_OPTIONS
#define VK_ENC_FLAG_NO_DELAY
const FFVulkanEncodeDescriptor ff_vk_enc_av1_desc
static int write_sequence_header(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
static int create_session_params(AVCodecContext *avctx)
static int write_padding(AVCodecContext *avctx, uint32_t padding, uint8_t *data, size_t *data_len)
static av_cold int vulkan_encode_av1_init(AVCodecContext *avctx)
static const AVOption vulkan_encode_av1_options[]
static int parse_feedback_units(AVCodecContext *avctx, const uint8_t *data, size_t size)
@ UNIT_CONTENT_LIGHT_LEVEL
static int init_profile(AVCodecContext *avctx, VkVideoProfileInfoKHR *profile, void *pnext)
#define LEVEL(name, value)
static int init_enc_options(AVCodecContext *avctx)
static av_cold int base_unit_to_vk(AVCodecContext *avctx, VulkanAV1Units *vk_units)
static int set_name_slot(int slot, int *slot_indices, uint32_t allowed_idx, int group)
static int vulkan_encode_av1_add_obu(AVCodecContext *avctx, CodedBitstreamFragment *au, uint8_t type, void *obu_unit)
static int init_pic_rc(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeRateControlInfoKHR *rc_info, VkVideoEncodeRateControlLayerInfoKHR *rc_layer)
static av_cold int vulkan_encode_av1_close(AVCodecContext *avctx)
static int write_extra_headers(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
static int init_pic_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeInfoKHR *encode_info)
#define PROFILE(name, value)
static const FFVulkanCodec enc_cb
static const AVClass vulkan_encode_av1_class
static av_cold int init_sequence_headers(AVCodecContext *avctx)
static int init_base_units(AVCodecContext *avctx)
static int vulkan_encode_av1_write_obu(AVCodecContext *avctx, uint8_t *data, size_t *data_len, CodedBitstreamFragment *obu)
static const FFCodecDefault vulkan_encode_av1_defaults[]
static int write_filler(AVCodecContext *avctx, uint32_t filler, uint8_t *data, size_t *data_len)
static int write_sequence_headers(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
#define FF_VK_EXT_VIDEO_ENCODE_AV1
StdVideoAV1Profile ff_vk_av1_profile_to_vk(int profile)