FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vulkan_encode_h264.c File Reference
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/mem.h"
#include "cbs.h"
#include "cbs_h264.h"
#include "atsc_a53.h"
#include "h264_levels.h"
#include "h2645data.h"
#include "codec_internal.h"
#include "version.h"
#include "hw_base_encode_h264.h"
#include "vulkan_encode.h"

Go to the source code of this file.

Data Structures

struct  VulkanEncodeH264Picture
 
struct  VulkanEncodeH264Context
 
struct  VulkanH264Units
 

Macros

#define OFFSET(x)   offsetof(VulkanEncodeH264Context, x)
 
#define FLAGS   (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 
#define PROFILE(name, value)
 
#define LEVEL(name, value)
 

Enumerations

enum  UnitElems {
  UNIT_AUD = 1 << 0, UNIT_SEI_TIMING = 1 << 1, UNIT_SEI_IDENTIFIER = 1 << 2, UNIT_SEI_RECOVERY = 1 << 3,
  UNIT_SEI_A53_CC = 1 << 4, UNIT_AUD = 1 << 0, UNIT_SEI_MASTERING_DISPLAY = 1 << 1, UNIT_SEI_CONTENT_LIGHT_LEVEL = 1 << 2,
  UNIT_SEI_A53_CC = 1 << 3
}
 

Functions

static int init_pic_rc (AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeRateControlInfoKHR *rc_info, VkVideoEncodeRateControlLayerInfoKHR *rc_layer)
 
static int vk_enc_h264_update_pic_info (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static void setup_slices (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static void vk_enc_h264_default_ref_pic_list (AVCodecContext *avctx, FFHWBaseEncodePicture *pic, FFHWBaseEncodePicture **rpl0, FFHWBaseEncodePicture **rpl1, int *rpl_size)
 
static void setup_refs (AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeInfoKHR *encode_info)
 
static int init_pic_params (AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeInfoKHR *encode_info)
 
static int init_profile (AVCodecContext *avctx, VkVideoProfileInfoKHR *profile, void *pnext)
 
static int init_enc_options (AVCodecContext *avctx)
 
static av_cold int init_sequence_headers (AVCodecContext *avctx)
 
static av_cold int base_unit_to_vk (AVCodecContext *avctx, VulkanH264Units *vk_units)
 
static int create_session_params (AVCodecContext *avctx)
 
static int parse_feedback_units (AVCodecContext *avctx, const uint8_t *data, size_t size, int sps_override, int pps_override)
 
static int init_base_units (AVCodecContext *avctx)
 
static int vulkan_encode_h264_add_nal (AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit)
 
static int write_access_unit (AVCodecContext *avctx, uint8_t *data, size_t *data_len, CodedBitstreamFragment *au)
 
static int write_sequence_headers (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
 
static int write_extra_headers (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
 
static int write_filler (AVCodecContext *avctx, uint32_t filler, uint8_t *data, size_t *data_len)
 
static av_cold int vulkan_encode_h264_init (AVCodecContext *avctx)
 
static av_cold int vulkan_encode_h264_close (AVCodecContext *avctx)
 

Variables

const FFVulkanEncodeDescriptor ff_vk_enc_h264_desc
 
static const uint8_t vulkan_encode_h264_sei_identifier_uuid [16]
 
static const FFVulkanCodec enc_cb
 
static const AVOption vulkan_encode_h264_options []
 
static const FFCodecDefault vulkan_encode_h264_defaults []
 
static const AVClass vulkan_encode_h264_class
 
const FFCodec ff_h264_vulkan_encoder
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 1565 of file vulkan_encode_h264.c.

◆ FLAGS

Definition at line 1566 of file vulkan_encode_h264.c.

◆ PROFILE

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

◆ LEVEL

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

Enumeration Type Documentation

◆ UnitElems

enum UnitElems
Enumerator
UNIT_AUD 
UNIT_SEI_TIMING 
UNIT_SEI_IDENTIFIER 
UNIT_SEI_RECOVERY 
UNIT_SEI_A53_CC 
UNIT_AUD 
UNIT_SEI_MASTERING_DISPLAY 
UNIT_SEI_CONTENT_LIGHT_LEVEL 
UNIT_SEI_A53_CC 

Definition at line 35 of file vulkan_encode_h264.c.

Function Documentation

◆ init_pic_rc()

static int init_pic_rc ( AVCodecContext avctx,
FFHWBaseEncodePicture pic,
VkVideoEncodeRateControlInfoKHR *  rc_info,
VkVideoEncodeRateControlLayerInfoKHR *  rc_layer 
)
static

Definition at line 117 of file vulkan_encode_h264.c.

◆ vk_enc_h264_update_pic_info()

static int vk_enc_h264_update_pic_info ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

Definition at line 162 of file vulkan_encode_h264.c.

Referenced by init_pic_params().

◆ setup_slices()

static void setup_slices ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

Definition at line 247 of file vulkan_encode_h264.c.

Referenced by init_pic_params().

◆ vk_enc_h264_default_ref_pic_list()

static void vk_enc_h264_default_ref_pic_list ( AVCodecContext avctx,
FFHWBaseEncodePicture pic,
FFHWBaseEncodePicture **  rpl0,
FFHWBaseEncodePicture **  rpl1,
int *  rpl_size 
)
static

Definition at line 310 of file vulkan_encode_h264.c.

Referenced by setup_refs().

◆ setup_refs()

static void setup_refs ( AVCodecContext avctx,
FFHWBaseEncodePicture pic,
VkVideoEncodeInfoKHR *  encode_info 
)
static

Definition at line 407 of file vulkan_encode_h264.c.

Referenced by init_pic_params().

◆ init_pic_params()

static int init_pic_params ( AVCodecContext avctx,
FFHWBaseEncodePicture pic,
VkVideoEncodeInfoKHR *  encode_info 
)
static

Definition at line 606 of file vulkan_encode_h264.c.

◆ init_profile()

static int init_profile ( AVCodecContext avctx,
VkVideoProfileInfoKHR *  profile,
void *  pnext 
)
static

Definition at line 679 of file vulkan_encode_h264.c.

◆ init_enc_options()

static int init_enc_options ( AVCodecContext avctx)
static

Definition at line 757 of file vulkan_encode_h264.c.

Referenced by vulkan_encode_h264_init().

◆ init_sequence_headers()

static av_cold int init_sequence_headers ( AVCodecContext avctx)
static

Definition at line 814 of file vulkan_encode_h264.c.

Referenced by init_base_units().

◆ base_unit_to_vk()

static av_cold int base_unit_to_vk ( AVCodecContext avctx,
VulkanH264Units vk_units 
)
static

Definition at line 857 of file vulkan_encode_h264.c.

Referenced by create_session_params().

◆ create_session_params()

static int create_session_params ( AVCodecContext avctx)
static

Definition at line 1006 of file vulkan_encode_h264.c.

Referenced by init_base_units().

◆ parse_feedback_units()

static int parse_feedback_units ( AVCodecContext avctx,
const uint8_t *  data,
size_t  size,
int  sps_override,
int  pps_override 
)
static

Definition at line 1050 of file vulkan_encode_h264.c.

Referenced by init_base_units().

◆ init_base_units()

static int init_base_units ( AVCodecContext avctx)
static

Definition at line 1088 of file vulkan_encode_h264.c.

Referenced by vulkan_encode_h264_init().

◆ vulkan_encode_h264_add_nal()

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

◆ write_access_unit()

static int write_access_unit ( AVCodecContext avctx,
uint8_t *  data,
size_t *  data_len,
CodedBitstreamFragment au 
)
static

◆ write_sequence_headers()

static int write_sequence_headers ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic,
uint8_t *  data,
size_t *  data_len 
)
static

Definition at line 1226 of file vulkan_encode_h264.c.

◆ write_extra_headers()

static int write_extra_headers ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic,
uint8_t *  data,
size_t *  data_len 
)
static

Definition at line 1255 of file vulkan_encode_h264.c.

◆ write_filler()

static int write_filler ( AVCodecContext avctx,
uint32_t  filler,
uint8_t *  data,
size_t *  data_len 
)
static

Definition at line 1322 of file vulkan_encode_h264.c.

◆ vulkan_encode_h264_init()

static av_cold int vulkan_encode_h264_init ( AVCodecContext avctx)
static

Definition at line 1360 of file vulkan_encode_h264.c.

◆ vulkan_encode_h264_close()

static av_cold int vulkan_encode_h264_close ( AVCodecContext avctx)
static

Definition at line 1558 of file vulkan_encode_h264.c.

Variable Documentation

◆ ff_vk_enc_h264_desc

const FFVulkanEncodeDescriptor ff_vk_enc_h264_desc
Initial value:
= {
.codec_id = AV_CODEC_ID_H264,
.encode_extension = FF_VK_EXT_VIDEO_ENCODE_H264,
.encode_op = VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR,
.ext_props = {
.extensionName = VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_EXTENSION_NAME,
.specVersion = VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_SPEC_VERSION,
},
}

Definition at line 43 of file vulkan_encode_h264.c.

Referenced by vulkan_encode_h264_init().

◆ vulkan_encode_h264_sei_identifier_uuid

const uint8_t vulkan_encode_h264_sei_identifier_uuid[16]
static
Initial value:
= {
0x03, 0xfd, 0xf2, 0x0a, 0x5d, 0x4c, 0x05, 0x48,
0x20, 0x98, 0xca, 0x6b, 0x0c, 0x95, 0x30, 0x1c,
}

Definition at line 54 of file vulkan_encode_h264.c.

Referenced by vulkan_encode_h264_init().

◆ enc_cb

const FFVulkanCodec enc_cb
static

◆ vulkan_encode_h264_options

const AVOption vulkan_encode_h264_options[]
static

Definition at line 1567 of file vulkan_encode_h264.c.

◆ vulkan_encode_h264_defaults

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

Definition at line 1624 of file vulkan_encode_h264.c.

◆ vulkan_encode_h264_class

const AVClass vulkan_encode_h264_class
static
Initial value:
= {
.class_name = "h264_vulkan",
.item_name = av_default_item_name,
}

Definition at line 1637 of file vulkan_encode_h264.c.

◆ ff_h264_vulkan_encoder

const FFCodec ff_h264_vulkan_encoder
Initial value:

Definition at line 1644 of file vulkan_encode_h264.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
FF_HW_FLAG_B_PICTURE_REFERENCES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
Definition: hw_base_encode.h:55
ff_vulkan_encode_hw_configs
const AVCodecHWConfigInternal *const ff_vulkan_encode_hw_configs[]
Paperwork.
Definition: vulkan_encode.c:26
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
vulkan_encode_h264_init
static av_cold int vulkan_encode_h264_init(AVCodecContext *avctx)
Definition: vulkan_encode_h264.c:1360
vulkan_encode_h264_close
static av_cold int vulkan_encode_h264_close(AVCodecContext *avctx)
Definition: vulkan_encode_h264.c:1558
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
write_extra_headers
static int write_extra_headers(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
Definition: vulkan_encode_h264.c:1255
AV_CODEC_CAP_ENCODER_FLUSH
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition: codec.h:166
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
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:79
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
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
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
VulkanEncodeH264Context
Definition: vulkan_encode_h264.c:88
VulkanEncodeH264Picture
Definition: vulkan_encode_h264.c:59
vulkan_encode_h264_options
static const AVOption vulkan_encode_h264_options[]
Definition: vulkan_encode_h264.c:1567
FLAGS
#define FLAGS
Definition: vulkan_encode_h264.c:1566
vulkan_encode_h264_defaults
static const FFCodecDefault vulkan_encode_h264_defaults[]
Definition: vulkan_encode_h264.c:1624
ff_vulkan_encode_receive_packet
int ff_vulkan_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Encode.
Definition: vulkan_encode.c:541
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
write_sequence_headers
static int write_sequence_headers(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
Definition: vulkan_encode_h264.c:1226
init_profile
static int init_profile(AVCodecContext *avctx, VkVideoProfileInfoKHR *profile, void *pnext)
Definition: vulkan_encode_h264.c:679
init_pic_rc
static int init_pic_rc(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeRateControlInfoKHR *rc_info, VkVideoEncodeRateControlLayerInfoKHR *rc_layer)
Definition: vulkan_encode_h264.c:117
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
vulkan_encode_h264_class
static const AVClass vulkan_encode_h264_class
Definition: vulkan_encode_h264.c:1637
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_VK_EXT_VIDEO_ENCODE_H264
#define FF_VK_EXT_VIDEO_ENCODE_H264
Definition: vulkan_functions.h:62
write_filler
static int write_filler(AVCodecContext *avctx, uint32_t filler, uint8_t *data, size_t *data_len)
Definition: vulkan_encode_h264.c:1322
init_pic_params
static int init_pic_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeInfoKHR *encode_info)
Definition: vulkan_encode_h264.c:606
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299