FFmpeg
Data Structures | Macros | Functions | Variables
vaapi_encode_av1.c File Reference
#include <va/va.h>
#include <va/va_enc_av1.h>
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "libavutil/mastering_display_metadata.h"
#include "cbs_av1.h"
#include "put_bits.h"
#include "codec_internal.h"
#include "av1_levels.h"
#include "vaapi_encode.h"

Go to the source code of this file.

Data Structures

struct  VAAPIEncodeAV1Picture
 
struct  VAAPIEncodeAV1Context
 

Macros

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

Functions

static void vaapi_encode_av1_trace_write_log (void *ctx, PutBitContext *pbc, int length, const char *str, const int *subscripts, int64_t value)
 
static av_cold int vaapi_encode_av1_get_encoder_caps (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_av1_configure (AVCodecContext *avctx)
 
static int vaapi_encode_av1_add_obu (AVCodecContext *avctx, CodedBitstreamFragment *au, uint8_t type, void *obu_unit)
 
static int vaapi_encode_av1_write_obu (AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *bs)
 
static int tile_log2 (int blkSize, int target)
 
static int vaapi_encode_av1_set_tile (AVCodecContext *avctx)
 
static int vaapi_encode_av1_write_sequence_header (AVCodecContext *avctx, char *data, size_t *data_len)
 
static int vaapi_encode_av1_init_sequence_params (AVCodecContext *avctx)
 
static int vaapi_encode_av1_init_picture_params (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static int vaapi_encode_av1_init_slice_params (AVCodecContext *avctx, FFHWBaseEncodePicture *base, VAAPIEncodeSlice *slice)
 
static int vaapi_encode_av1_write_picture_header (AVCodecContext *avctx, FFHWBaseEncodePicture *pic, char *data, size_t *data_len)
 
static int vaapi_encode_av1_write_extra_header (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, int index, int *type, char *data, size_t *data_len)
 
static av_cold int vaapi_encode_av1_init (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_av1_close (AVCodecContext *avctx)
 

Variables

static const VAAPIEncodeProfile vaapi_encode_av1_profiles []
 
static const VAAPIEncodeType vaapi_encode_type_av1
 
static const AVOption vaapi_encode_av1_options []
 
static const FFCodecDefault vaapi_encode_av1_defaults []
 
static const AVClass vaapi_encode_av1_class
 
const FFCodec ff_av1_vaapi_encoder
 

Macro Definition Documentation

◆ AV1_MAX_QUANT

#define AV1_MAX_QUANT   255

Definition at line 34 of file vaapi_encode_av1.c.

◆ OFFSET

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

Definition at line 967 of file vaapi_encode_av1.c.

◆ FLAGS

Definition at line 968 of file vaapi_encode_av1.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"

Function Documentation

◆ vaapi_encode_av1_trace_write_log()

static void vaapi_encode_av1_trace_write_log ( void *  ctx,
PutBitContext pbc,
int  length,
const char *  str,
const int *  subscripts,
int64_t  value 
)
static

Definition at line 92 of file vaapi_encode_av1.c.

Referenced by vaapi_encode_av1_configure().

◆ vaapi_encode_av1_get_encoder_caps()

static av_cold int vaapi_encode_av1_get_encoder_caps ( AVCodecContext avctx)
static

Definition at line 113 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_configure()

static av_cold int vaapi_encode_av1_configure ( AVCodecContext avctx)
static

Arbitrary value

Definition at line 125 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_add_obu()

static int vaapi_encode_av1_add_obu ( AVCodecContext avctx,
CodedBitstreamFragment au,
uint8_t  type,
void *  obu_unit 
)
static

◆ vaapi_encode_av1_write_obu()

static int vaapi_encode_av1_write_obu ( AVCodecContext avctx,
char *  data,
size_t *  data_len,
CodedBitstreamFragment bs 
)
static

◆ tile_log2()

static int tile_log2 ( int  blkSize,
int  target 
)
static

Definition at line 210 of file vaapi_encode_av1.c.

Referenced by vaapi_encode_av1_set_tile().

◆ vaapi_encode_av1_set_tile()

static int vaapi_encode_av1_set_tile ( AVCodecContext avctx)
static

Try user setting tile rows number first.

try uniformed tile.

try non-uniformed tile.

Return invalid parameter if explicit tile rows is set.

check if tile cols/rows is supported by driver.

check if tile group numbers is valid.

Definition at line 216 of file vaapi_encode_av1.c.

Referenced by vaapi_encode_av1_init().

◆ vaapi_encode_av1_write_sequence_header()

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

Definition at line 350 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_init_sequence_params()

static int vaapi_encode_av1_init_sequence_params ( AVCodecContext avctx)
static

enable order hint and reserve maximum 8 bits for it by default.

Definition at line 361 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_init_picture_params()

static int vaapi_encode_av1_init_picture_params ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

set the nearest frame in L0 as all reference frame.

set the 2nd nearest frame in L0 as Golden frame.

B frame will not be referenced, disable its recon frame.

Use LAST_FRAME and BWDREF_FRAME for reference.

ignore ONLY_4x4 mode for codedlossless is not fully implemented.

let driver decide to use single or compound reference prediction mode.

set reference.

Definition at line 468 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_init_slice_params()

static int vaapi_encode_av1_init_slice_params ( AVCodecContext avctx,
FFHWBaseEncodePicture base,
VAAPIEncodeSlice slice 
)
static

Set tile group info.

Definition at line 734 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_write_picture_header()

static int vaapi_encode_av1_write_picture_header ( AVCodecContext avctx,
FFHWBaseEncodePicture pic,
char *  data,
size_t *  data_len 
)
static

Pack repeat frame header.

Definition at line 756 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_write_extra_header()

static int vaapi_encode_av1_write_extra_header ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic,
int  index,
int *  type,
char *  data,
size_t *  data_len 
)
static

Definition at line 806 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_init()

static av_cold int vaapi_encode_av1_init ( AVCodecContext avctx)
static

This attr provides essential indicators, return error if not support.

Definition at line 870 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_close()

static av_cold int vaapi_encode_av1_close ( AVCodecContext avctx)
static

Definition at line 957 of file vaapi_encode_av1.c.

Variable Documentation

◆ vaapi_encode_av1_profiles

const VAAPIEncodeProfile vaapi_encode_av1_profiles[]
static
Initial value:
= {
{ AV_PROFILE_AV1_MAIN, 8, 3, 1, 1, VAProfileAV1Profile0 },
{ AV_PROFILE_AV1_MAIN, 10, 3, 1, 1, VAProfileAV1Profile0 },
}

Definition at line 839 of file vaapi_encode_av1.c.

◆ vaapi_encode_type_av1

const VAAPIEncodeType vaapi_encode_type_av1
static
Initial value:
= {
.default_quality = 25,
.get_encoder_caps = &vaapi_encode_av1_get_encoder_caps,
.sequence_header_type = VAEncPackedHeaderSequence,
.sequence_params_size = sizeof(VAEncSequenceParameterBufferAV1),
.init_sequence_params = &vaapi_encode_av1_init_sequence_params,
.write_sequence_header = &vaapi_encode_av1_write_sequence_header,
.picture_priv_data_size = sizeof(VAAPIEncodeAV1Picture),
.picture_header_type = VAEncPackedHeaderPicture,
.picture_params_size = sizeof(VAEncPictureParameterBufferAV1),
.init_picture_params = &vaapi_encode_av1_init_picture_params,
.write_picture_header = &vaapi_encode_av1_write_picture_header,
.slice_params_size = sizeof(VAEncTileGroupBufferAV1),
.init_slice_params = &vaapi_encode_av1_init_slice_params,
.write_extra_header = &vaapi_encode_av1_write_extra_header,
}

Definition at line 845 of file vaapi_encode_av1.c.

Referenced by vaapi_encode_av1_init().

◆ vaapi_encode_av1_options

const AVOption vaapi_encode_av1_options[]
static

Definition at line 970 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_defaults

const FFCodecDefault vaapi_encode_av1_defaults[]
static
Initial value:
= {
{ "b", "0" },
{ "bf", "2" },
{ "g", "120" },
{ "qmin", "1" },
{ "qmax", "255" },
{ NULL },
}

Definition at line 1021 of file vaapi_encode_av1.c.

◆ vaapi_encode_av1_class

const AVClass vaapi_encode_av1_class
static
Initial value:
= {
.class_name = "av1_vaapi",
.item_name = av_default_item_name,
}

Definition at line 1030 of file vaapi_encode_av1.c.

◆ ff_av1_vaapi_encoder

const FFCodec ff_av1_vaapi_encoder
Initial value:

Definition at line 1037 of file vaapi_encode_av1.c.

vaapi_encode_av1_init
static av_cold int vaapi_encode_av1_init(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:870
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
FLAGS
#define FLAGS
Definition: vaapi_encode_av1.c:968
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
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
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:696
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
vaapi_encode_av1_profiles
static const VAAPIEncodeProfile vaapi_encode_av1_profiles[]
Definition: vaapi_encode_av1.c:839
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
vaapi_encode_av1_init_sequence_params
static int vaapi_encode_av1_init_sequence_params(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:361
FLAG_TIMESTAMP_NO_DELAY
#define FLAG_TIMESTAMP_NO_DELAY
Definition: vaapi_encode.h:42
vaapi_encode_av1_write_sequence_header
static int vaapi_encode_av1_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
Definition: vaapi_encode_av1.c:350
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
vaapi_encode_av1_init_picture_params
static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: vaapi_encode_av1.c:468
ff_vaapi_encode_receive_packet
int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: vaapi_encode.c:2086
vaapi_encode_av1_init_slice_params
static int vaapi_encode_av1_init_slice_params(AVCodecContext *avctx, FFHWBaseEncodePicture *base, VAAPIEncodeSlice *slice)
Definition: vaapi_encode_av1.c:734
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
VAAPIEncodeAV1Context
Definition: vaapi_encode_av1.c:41
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:280
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
vaapi_encode_av1_close
static av_cold int vaapi_encode_av1_close(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:957
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
vaapi_encode_av1_options
static const AVOption vaapi_encode_av1_options[]
Definition: vaapi_encode_av1.c:970
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:126
vaapi_encode_av1_class
static const AVClass vaapi_encode_av1_class
Definition: vaapi_encode_av1.c:1030
VAAPIEncodeAV1Picture
Definition: vaapi_encode_av1.c:36
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
vaapi_encode_av1_write_extra_header
static int vaapi_encode_av1_write_extra_header(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, int index, int *type, char *data, size_t *data_len)
Definition: vaapi_encode_av1.c:806
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:679
ff_vaapi_encode_hw_configs
const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]
Definition: vaapi_encode.c:36
vaapi_encode_av1_get_encoder_caps
static av_cold int vaapi_encode_av1_get_encoder_caps(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:113
vaapi_encode_av1_defaults
static const FFCodecDefault vaapi_encode_av1_defaults[]
Definition: vaapi_encode_av1.c:1021
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
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
vaapi_encode_av1_write_picture_header
static int vaapi_encode_av1_write_picture_header(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, char *data, size_t *data_len)
Definition: vaapi_encode_av1.c:756
AV_PROFILE_AV1_MAIN
#define AV_PROFILE_AV1_MAIN
Definition: defs.h:169
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
vaapi_encode_av1_configure
static av_cold int vaapi_encode_av1_configure(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:125