FFmpeg
Loading...
Searching...
No Matches
apv_encode_vulkan.c File Reference
#include <math.h>
#include <stdlib.h>
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/vulkan.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
#include "hwconfig.h"
#include "internal.h"
#include "apv.h"
#include "cbs.h"
#include "cbs_apv.h"

Go to the source code of this file.

Data Structures

struct  DCTPushData
 
struct  EntropyPushData
 
struct  CompactPushData
 
struct  VulkanEncodeAPVFrameData
 
struct  VulkanEncodeAPVContext
 

Macros

#define APV_DEFAULT_QMAT   16
 
#define APV_MAX_NUM_COMP   4
 
#define OFFSET(x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  { APV_QMATRIX_FLAT = 0 , APV_QMATRIX_HEVC = 1 }
 

Functions

static int apv_qmatrix_value (int qmatrix, int i)
 
static int chroma_format_from_pix_fmt (enum AVPixelFormat sw_fmt)
 
static int profile_idc_from_pix_fmt (enum AVPixelFormat sw_fmt)
 
static int init_dct_shader (AVCodecContext *avctx)
 
static int init_entropy_shader (AVCodecContext *avctx, int blocks_per_mb, FFVulkanShader *shd)
 
static int init_compact_shader (AVCodecContext *avctx)
 
static void build_dct_push_const (AVCodecContext *avctx)
 
static int submit_frame (AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *frame)
 
static int build_packet (AVCodecContext *avctx, FFVkExecContext *exec, AVPacket *pkt)
 
static int vulkan_encode_apv_receive_packet (AVCodecContext *avctx, AVPacket *pkt)
 
static av_cold int vulkan_encode_apv_close (AVCodecContext *avctx)
 
static av_cold int vulkan_encode_apv_init (AVCodecContext *avctx)
 

Variables

const unsigned char ff_apv_encode_dct_comp_spv_data []
 
const unsigned int ff_apv_encode_dct_comp_spv_len
 
const unsigned char ff_apv_encode_tiles_comp_spv_data []
 
const unsigned int ff_apv_encode_tiles_comp_spv_len
 
const unsigned char ff_seg_gather_comp_spv_data []
 
const unsigned int ff_seg_gather_comp_spv_len
 
static const uint8_t apv_qmat_hevc_intra [64]
 
static const uint8_t apv_level_scale [6] = { 40, 45, 51, 57, 64, 71 }
 
static const AVOption vulkan_encode_apv_options []
 
static const FFCodecDefault vulkan_encode_apv_defaults []
 
static const AVClass vulkan_encode_apv_class
 
static const AVCodecHWConfigInternal *const vulkan_encode_apv_hw_configs []
 
const FFCodec ff_apv_vulkan_encoder
 

Macro Definition Documentation

◆ APV_DEFAULT_QMAT

#define APV_DEFAULT_QMAT   16

Definition at line 48 of file apv_encode_vulkan.c.

Referenced by apv_qmatrix_value().

◆ APV_MAX_NUM_COMP

#define APV_MAX_NUM_COMP   4

Definition at line 49 of file apv_encode_vulkan.c.

Referenced by build_dct_push_const(), and vk_apv_start_frame().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 1074 of file apv_encode_vulkan.c.

◆ VE

Definition at line 1075 of file apv_encode_vulkan.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
APV_QMATRIX_FLAT 
APV_QMATRIX_HEVC 

Definition at line 180 of file apv_encode_vulkan.c.

Function Documentation

◆ apv_qmatrix_value()

static int apv_qmatrix_value ( int qmatrix,
int i )
static

Definition at line 191 of file apv_encode_vulkan.c.

Referenced by build_dct_push_const(), and build_packet().

◆ chroma_format_from_pix_fmt()

static int chroma_format_from_pix_fmt ( enum AVPixelFormat sw_fmt)
static

Definition at line 199 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_init().

◆ profile_idc_from_pix_fmt()

static int profile_idc_from_pix_fmt ( enum AVPixelFormat sw_fmt)
static

Definition at line 219 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_init().

◆ init_dct_shader()

static int init_dct_shader ( AVCodecContext * avctx)
static

Definition at line 233 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_init().

◆ init_entropy_shader()

static int init_entropy_shader ( AVCodecContext * avctx,
int blocks_per_mb,
FFVulkanShader * shd )
static

Definition at line 273 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_init().

◆ init_compact_shader()

static int init_compact_shader ( AVCodecContext * avctx)
static

Definition at line 314 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_init().

◆ build_dct_push_const()

static void build_dct_push_const ( AVCodecContext * avctx)
static

Definition at line 350 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_init().

◆ submit_frame()

static int submit_frame ( AVCodecContext * avctx,
FFVkExecContext * exec,
AVFrame * frame )
static

Definition at line 391 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_receive_packet().

◆ build_packet()

static int build_packet ( AVCodecContext * avctx,
FFVkExecContext * exec,
AVPacket * pkt )
static

Definition at line 633 of file apv_encode_vulkan.c.

Referenced by vulkan_encode_apv_receive_packet().

◆ vulkan_encode_apv_receive_packet()

static int vulkan_encode_apv_receive_packet ( AVCodecContext * avctx,
AVPacket * pkt )
static

Definition at line 789 of file apv_encode_vulkan.c.

◆ vulkan_encode_apv_close()

static av_cold int vulkan_encode_apv_close ( AVCodecContext * avctx)
static

Definition at line 839 of file apv_encode_vulkan.c.

◆ vulkan_encode_apv_init()

static av_cold int vulkan_encode_apv_init ( AVCodecContext * avctx)
static

Definition at line 877 of file apv_encode_vulkan.c.

Variable Documentation

◆ ff_apv_encode_dct_comp_spv_data

const unsigned char ff_apv_encode_dct_comp_spv_data[]
extern

Referenced by init_dct_shader().

◆ ff_apv_encode_dct_comp_spv_len

const unsigned int ff_apv_encode_dct_comp_spv_len
extern

Referenced by init_dct_shader().

◆ ff_apv_encode_tiles_comp_spv_data

const unsigned char ff_apv_encode_tiles_comp_spv_data[]
extern

Referenced by init_entropy_shader().

◆ ff_apv_encode_tiles_comp_spv_len

const unsigned int ff_apv_encode_tiles_comp_spv_len
extern

Referenced by init_entropy_shader().

◆ ff_seg_gather_comp_spv_data

const unsigned char ff_seg_gather_comp_spv_data[]
extern

◆ ff_seg_gather_comp_spv_len

const unsigned int ff_seg_gather_comp_spv_len
extern

◆ apv_qmat_hevc_intra

const uint8_t apv_qmat_hevc_intra[64]
static
Initial value:
= {
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115,
}

Definition at line 169 of file apv_encode_vulkan.c.

Referenced by apv_qmatrix_value().

◆ apv_level_scale

const uint8_t apv_level_scale[6] = { 40, 45, 51, 57, 64, 71 }
static

Definition at line 197 of file apv_encode_vulkan.c.

Referenced by apv_decode_tile_component(), and build_dct_push_const().

◆ vulkan_encode_apv_options

const AVOption vulkan_encode_apv_options[]
static
Initial value:
= {
{ "qp", "Quantization parameter (luma)", OFFSET(qp_y),
AV_OPT_TYPE_INT, { .i64 = 22 }, 0, 255, VE },
{ "qp_chroma", "Chroma quantization parameter (0 = same as luma qp)", OFFSET(qp_c),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 255, VE },
{ "qmatrix", "Quantization matrix", OFFSET(qmatrix),
AV_OPT_TYPE_INT, { .i64 = APV_QMATRIX_HEVC }, 0, 1, VE, "qmatrix" },
{ "flat", "Uniform matrix, all 16 (APV spec default)", 0,
AV_OPT_TYPE_CONST, { .i64 = APV_QMATRIX_FLAT }, 0, 0, VE, "qmatrix" },
{ "hevc", "HEVC default intra scaling list (mild perceptual shaping)", 0,
AV_OPT_TYPE_CONST, { .i64 = APV_QMATRIX_HEVC }, 0, 0, VE, "qmatrix" },
{ "tile_width", "Tile width in macroblocks (0 = adaptive, auto-sized per frame)", OFFSET(tile_w_mbs_opt),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 32, VE },
{ "tile_height", "Tile height in macroblocks (0 = adaptive, auto-sized per frame)", OFFSET(tile_h_mbs_opt),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 16, VE },
{ "async_depth", "Internal parallelization depth", OFFSET(async_depth),
AV_OPT_TYPE_INT, { .i64 = 1 }, 1, INT_MAX, VE },
{ NULL }
}
#define VE
Definition amfenc_av1.c:30
@ APV_QMATRIX_FLAT
@ APV_QMATRIX_HEVC
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258

Definition at line 1076 of file apv_encode_vulkan.c.

◆ vulkan_encode_apv_defaults

const FFCodecDefault vulkan_encode_apv_defaults[]
static
Initial value:
= {
{ "g", "1" },
{ NULL },
}

Definition at line 1100 of file apv_encode_vulkan.c.

◆ vulkan_encode_apv_class

const AVClass vulkan_encode_apv_class
static
Initial value:
= {
.class_name = "apv_vulkan",
.item_name = av_default_item_name,
}
static const AVOption vulkan_encode_apv_options[]
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 1105 of file apv_encode_vulkan.c.

◆ vulkan_encode_apv_hw_configs

const AVCodecHWConfigInternal* const vulkan_encode_apv_hw_configs[]
static
Initial value:
= {
HW_CONFIG_ENCODER_FRAMES(VULKAN, VULKAN),
}
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition hwconfig.h:100

Definition at line 1112 of file apv_encode_vulkan.c.

◆ ff_apv_vulkan_encoder

const FFCodec ff_apv_vulkan_encoder
Initial value:
= {
.p.name = "apv_vulkan",
CODEC_LONG_NAME("Advanced Professional Video (Vulkan)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_APV,
.priv_data_size = sizeof(VulkanEncodeAPVContext),
.p.priv_class = &vulkan_encode_apv_class,
.p.capabilities = AV_CODEC_CAP_DELAY |
.p.wrapper_name = "vulkan",
}
static int vulkan_encode_apv_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
static av_cold int vulkan_encode_apv_init(AVCodecContext *avctx)
static const AVCodecHWConfigInternal *const vulkan_encode_apv_hw_configs[]
static const AVClass vulkan_encode_apv_class
static av_cold int vulkan_encode_apv_close(AVCodecContext *avctx)
static const FFCodecDefault vulkan_encode_apv_defaults[]
#define FF_CODEC_CAP_EOF_FLUSH
The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it only wants to be flushe...
#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...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#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:147
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition codec.h:154
#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:79
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition codec.h:133
@ AV_CODEC_ID_APV
Definition codec_id.h:323
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition pixfmt.h:379

Definition at line 1117 of file apv_encode_vulkan.c.