FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
libsvtav1.c File Reference
#include <stdint.h>
#include <EbSvtAv1ErrorCodes.h>
#include <EbSvtAv1Enc.h>
#include <EbSvtAv1Metadata.h>
#include "libavutil/common.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avassert.h"
#include "codec_internal.h"
#include "dovi_rpu.h"
#include "encode.h"
#include "packet_internal.h"
#include "avcodec.h"
#include "profiles.h"

Go to the source code of this file.

Data Structures

struct  SvtContext
 

Macros

#define OFFSET(x)   offsetof(SvtContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define LEVEL(name, value)
 

Enumerations

enum  eos_status { EOS_NOT_REACHED = 0, EOS_SENT, EOS_RECEIVED }
 

Functions

static int svt_map_error (EbErrorType eb_err, const char **desc)
 
static int svt_print_error (void *log_ctx, EbErrorType err, const char *error_string)
 
static int alloc_buffer (EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
 
static void handle_mdcv (struct EbSvtAv1MasteringDisplayInfo *dst, const AVMasteringDisplayMetadata *mdcv)
 
static void handle_side_data (AVCodecContext *avctx, EbSvtAv1EncConfiguration *param)
 
static int config_enc_params (EbSvtAv1EncConfiguration *param, AVCodecContext *avctx)
 
static int read_in_data (EbSvtAv1EncConfiguration *param, const AVFrame *frame, EbBufferHeaderType *header_ptr)
 
static av_cold int eb_enc_init (AVCodecContext *avctx)
 
static int eb_send_frame (AVCodecContext *avctx, const AVFrame *frame)
 
static AVBufferRefget_output_ref (AVCodecContext *avctx, SvtContext *svt_enc, int filled_len)
 
static int eb_receive_packet (AVCodecContext *avctx, AVPacket *pkt)
 
static av_cold int eb_enc_close (AVCodecContext *avctx)
 

Variables

struct {
   EbErrorType   eb_err
 
   int   av_err
 
   const char *   desc
 
svt_errors []
 
static const AVOption options []
 
class {
      class_name = "libsvtav1"
 
      item_name = av_default_item_name
 
      option = options
 
      version = LIBAVUTIL_VERSION_INT
 
}; 
 
static const FFCodecDefault eb_enc_defaults []
 
const FFCodec ff_libsvtav1_encoder
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 693 of file libsvtav1.c.

◆ VE

Definition at line 694 of file libsvtav1.c.

◆ LEVEL

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

Enumeration Type Documentation

◆ eos_status

enum eos_status
Enumerator
EOS_NOT_REACHED 
EOS_SENT 
EOS_RECEIVED 

Definition at line 45 of file libsvtav1.c.

Function Documentation

◆ svt_map_error()

static int svt_map_error ( EbErrorType  eb_err,
const char **  desc 
)
static

Definition at line 95 of file libsvtav1.c.

Referenced by svt_print_error().

◆ svt_print_error()

static int svt_print_error ( void *  log_ctx,
EbErrorType  err,
const char *  error_string 
)
static

Definition at line 110 of file libsvtav1.c.

Referenced by eb_enc_init(), eb_receive_packet(), and eb_send_frame().

◆ alloc_buffer()

static int alloc_buffer ( EbSvtAv1EncConfiguration *  config,
SvtContext svt_enc 
)
static

Definition at line 121 of file libsvtav1.c.

Referenced by eb_enc_init().

◆ handle_mdcv()

static void handle_mdcv ( struct EbSvtAv1MasteringDisplayInfo *  dst,
const AVMasteringDisplayMetadata mdcv 
)
static

Definition at line 145 of file libsvtav1.c.

Referenced by handle_side_data().

◆ handle_side_data()

static void handle_side_data ( AVCodecContext avctx,
EbSvtAv1EncConfiguration *  param 
)
static

Definition at line 183 of file libsvtav1.c.

Referenced by config_enc_params().

◆ config_enc_params()

static int config_enc_params ( EbSvtAv1EncConfiguration *  param,
AVCodecContext avctx 
)
static

Definition at line 208 of file libsvtav1.c.

Referenced by eb_enc_init().

◆ read_in_data()

static int read_in_data ( EbSvtAv1EncConfiguration *  param,
const AVFrame frame,
EbBufferHeaderType *  header_ptr 
)
static

Definition at line 392 of file libsvtav1.c.

Referenced by eb_send_frame().

◆ eb_enc_init()

static av_cold int eb_enc_init ( AVCodecContext avctx)
static

Definition at line 430 of file libsvtav1.c.

◆ eb_send_frame()

static int eb_send_frame ( AVCodecContext avctx,
const AVFrame frame 
)
static

Definition at line 495 of file libsvtav1.c.

Referenced by eb_receive_packet().

◆ get_output_ref()

static AVBufferRef* get_output_ref ( AVCodecContext avctx,
SvtContext svt_enc,
int  filled_len 
)
static

Definition at line 565 of file libsvtav1.c.

Referenced by eb_receive_packet().

◆ eb_receive_packet()

static int eb_receive_packet ( AVCodecContext avctx,
AVPacket pkt 
)
static

Definition at line 589 of file libsvtav1.c.

◆ eb_enc_close()

static av_cold int eb_enc_close ( AVCodecContext avctx)
static

Definition at line 672 of file libsvtav1.c.

Variable Documentation

◆ eb_err

EbErrorType eb_err

Definition at line 77 of file libsvtav1.c.

Referenced by svt_map_error().

◆ av_err

int av_err

Definition at line 78 of file libsvtav1.c.

◆ desc

const char* desc

Definition at line 79 of file libsvtav1.c.

Referenced by alloc_base_frame(), alloc_enhanced_frame(), any_vscale(), aom_init(), apply_film_grain(), asf_read_picture(), asf_write_header1(), av_bsf_init(), av_film_grain_params_select(), av_frame_apply_cropping(), av_frame_side_data_add(), av_frame_side_data_clone(), av_frame_side_data_name(), av_frame_side_data_new(), av_guess_frame_rate(), av_image_alloc(), av_image_copy_to_buffer(), av_image_fill_black(), av_image_fill_color(), av_image_fill_linesizes(), av_image_fill_plane_sizes(), av_image_get_buffer_size(), av_image_get_linesize(), av_pix_fmt_count_planes(), av_pix_fmt_desc_get_id(), av_pix_fmt_get_chroma_sub_sample(), av_pix_fmt_swap_endianness(), av_read_image_line(), av_read_image_line2(), av_write_image_line(), av_write_image_line2(), avcodec_align_dimensions(), avcodec_align_dimensions2(), avcodec_default_get_format(), avcodec_descriptor_get_by_name(), avcodec_get_type(), avcodec_profile_name(), avformat_find_stream_info(), calc_cropping_offsets(), cbs_alloc_content(), cbs_clone_noncomplex_unit_content(), cbs_clone_unit_content(), cbs_default_free_unit_content(), cbs_find_unit_type_desc(), check_chrConvertRange(), check_image_fill_black(), check_image_pointers(), check_input_planar_rgb_to_a(), check_input_planar_rgb_to_uv(), check_input_planar_rgb_to_y(), check_lumConvertRange(), check_output_yuv2gbrp(), check_rgb_to_uv(), check_rgb_to_y(), choose_pixel_fmt(), chr_convert(), chr_h_scale(), chr_planar_vscale(), color_frame(), config_enc_params(), config_input(), config_input0(), config_input1(), config_input_main(), config_input_ref(), config_input_structure(), config_inputx(), config_inputy(), config_out_props(), config_output(), config_props(), config_props_output(), configure_input_video_filter(), copy_picture_field(), copy_uv_planes(), count_ports(), create_d3d11_pointer_tex(), d3d11va_device_create(), d3d11va_get_buffer(), d3d11va_transfer_data(), d3d12va_create_decoder(), d3d12va_create_decoder_heap(), d3d12va_create_encoder(), d3d12va_create_encoder_heap(), d3d12va_create_staging_buffer_resource(), d3d12va_device_create(), d3d12va_encode_alloc_output_buffer(), d3d12va_encode_hevc_init_sequence_params(), d3d12va_encode_set_profile(), d3d12va_get_valid_helper_objects(), d3d12va_pool_alloc(), ddagrab_request_frame(), dec_standalone_open(), decode(), decode_frame(), descriptor_compare(), deshake_opencl_init(), drm_map_frame(), enc_open(), encode_frame(), encode_init(), ff_aom_apply_film_grain(), ff_aom_image_copy_16_to_8(), ff_boxblur_eval_filter_params(), ff_cbs_alloc_unit_content(), ff_cbs_sei_add_message(), ff_cbs_sei_alloc_message_payload(), ff_draw_color(), ff_draw_horiz_band(), ff_draw_init2(), ff_fill_ayuv_map(), ff_fill_rgba_map(), ff_flac_parse_picture(), ff_fmt_align(), ff_fmt_from_frame(), ff_fmt_is_regular_yuv(), ff_formats_pixdesc_filter(), ff_frame_pool_get(), ff_frame_to_dnn_classify(), ff_get_format(), ff_guess_coded_bitrate(), ff_h264_draw_horiz_band(), ff_hscale16to15_4_neon(), ff_hscale16to15_X4_neon(), ff_hscale16to15_X8_neon(), ff_hscale16to19_4_neon(), ff_hscale16to19_X4_neon(), ff_hscale16to19_X8_neon(), ff_hscale_16_to_15_lasx(), ff_hscale_16_to_15_lsx(), ff_hscale_16_to_19_lasx(), ff_hscale_16_to_19_lsx(), ff_hw_base_encode_init_params_h264(), ff_hw_base_encode_init_params_h265(), ff_id3v2_write_apic(), ff_init_desc_cfmt_convert(), ff_init_desc_chscale(), ff_init_desc_fmt_convert(), ff_init_desc_hscale(), ff_init_desc_no_chr(), ff_init_gamma_convert(), ff_init_vscale(), ff_lut3d_init_x86(), ff_mediacodec_dec_init(), ff_rgb48Toxyz12(), ff_scale_eval_dimensions(), ff_sws_alphablendaway(), ff_sws_init_output_funcs(), ff_swscale(), ff_vk_shader_add_descriptor_set(), ff_vk_subsampling_from_av_desc(), ff_vmafmotion_init(), ff_vulkan_encode_init(), ff_xyz12Torgb48(), fill_map(), fill_texture_ptrs(), filter_frame(), find_codec(), flac_write_picture(), format_init(), gamma_convert(), generate_output(), geq_config_props(), get_aspect_ratio(), get_bit_depth(), get_cm_codec_type(), get_codecs_sorted(), get_color_type(), get_cv_pixel_info(), get_deinterleaved_format(), get_format(), get_mimetype(), get_pix_fmt_depth(), get_plane_wh(), get_video_buffer(), get_vt_hevc_profile_level(), graph_parse(), graphs_build(), h264_metadata_update_sps(), h265_metadata_guess_level(), handle_connect_error(), have_alpha_planar(), hScale16To15_c(), hScale16To19_c(), hwmap_config_output(), iccgen_filter_frame(), image_copy(), image_get_linesize(), init(), init_filter(), init_image(), init_muxer(), init_profile(), init_sec_buffer_desc(), init_video_param(), init_video_param_jpeg(), init_vulkan(), is16BPS(), is32BPS(), is_planar_yuv(), isALPHA(), isAnyRGB(), isBayer(), isBayer16BPS(), isBE(), isDataInHighBits(), isFloat(), isFloat16(), isGray(), isNBPS(), isPacked(), isPackedRGB(), isPlanar(), isPlanarRGB(), isPlanarYUV(), isRGB(), isSemiPlanarYUV(), isSwappedChroma(), isYUV(), j2kenc_init(), kmsgrab_free_desc(), kmsgrab_get_fb(), kmsgrab_read_packet(), libjxl_get_primaries(), libjxl_populate_primaries(), libplacebo_config_output(), libplacebo_query_format(), librav1e_encode_init(), librav1e_receive_packet(), libx265_encode_init(), list_formats(), log_encoder_error(), lum_convert(), lum_h_scale(), lum_planar_vscale(), lut2_config_output(), main(), map_pixel_format(), message(), mj2_create_image(), mux_log_debug_ts(), mxf_write_ffv1_desc(), next_frame_internal(), nlmeans_opencl_filter_frame(), no_chr_scale(), nppsharpen_sharpen(), opencl_frames_uninit(), opencl_get_buffer(), opencl_get_plane_format(), opencl_pool_alloc(), opencl_pool_free(), opengl_draw(), opengl_fill_color_map(), opengl_get_plane_pointer(), opengl_init_context(), packed_vscale(), pad_opencl_init(), param_init(), pick_format(), pix_fmt_match(), png_get_chrm(), populate_avctx_color_fields(), prepare_uv_scale(), print_codec(), print_codecs(), print_digraph(), print_stream_maps(), probe_output_format(), qsv_fill_border(), qsv_init_surface(), qsv_map_from(), qsvenc_fill_padding_area(), query_formats(), raw_decode(), raw_encode_init(), raw_init_decoder(), rawvideo_read_header(), read_gab2_sub(), read_packet_vs(), realign_frame(), remap_opencl_load(), rfc4175_parse_format(), rkmpp_release_frame(), rkmpp_retrieve_frame(), rv10_write_header(), scale_eval_dimensions(), scale_frame(), set_aes_arg(), set_dimensions(), set_format(), set_pix_fmt(), set_string_fmt(), show_codecs(), show_help_codec(), show_help_muxer(), sps_map_pixel_format(), svt_map_error(), svt_print_error(), tb_unreliable(), tiff_unpack_strip(), tonemap(), tonemap_slice(), unsharp_opencl_make_filter_params(), unsupported_codec(), update_set_descriptor(), v4l2_buffer_swframe_to_buf(), v4l2_encode_init(), v4l2_read_header(), vaapi_device_create(), vaapi_encode_av1_init_sequence_params(), vaapi_encode_mjpeg_get_encoder_caps(), vaapi_encode_mjpeg_init_picture_params(), vaapi_encode_profile_entrypoint(), vaapi_frames_init(), vaapi_map_frame(), vaapi_pix_fmt_from_fourcc(), vaapi_vpp_frame_is_rgb(), validate_avframe_allocation(), verify_md5(), video_frame_cksum(), vulkan_setup_profile(), vulkan_transfer_frame(), wrap_texture_buf(), write_header(), write_packet(), xwd_encode_frame(), yuv2gbrp16_full_X_c(), yuv2gbrp_full_X_c(), yuv2gbrpf32_full_X_c(), and yuv4_write_packet().

◆ svt_errors

const { ... } svt_errors[]
Initial value:
= {
{ EB_ErrorNone, 0, "success" },
{ EB_ErrorInsufficientResources, AVERROR(ENOMEM), "insufficient resources" },
{ EB_ErrorUndefined, AVERROR(EINVAL), "undefined error" },
{ EB_ErrorInvalidComponent, AVERROR(EINVAL), "invalid component" },
{ EB_ErrorBadParameter, AVERROR(EINVAL), "bad parameter" },
{ EB_ErrorDestroyThreadFailed, AVERROR_EXTERNAL, "failed to destroy thread" },
{ EB_ErrorSemaphoreUnresponsive, AVERROR_EXTERNAL, "semaphore unresponsive" },
{ EB_ErrorDestroySemaphoreFailed, AVERROR_EXTERNAL, "failed to destroy semaphore"},
{ EB_ErrorCreateMutexFailed, AVERROR_EXTERNAL, "failed to create mutex" },
{ EB_ErrorMutexUnresponsive, AVERROR_EXTERNAL, "mutex unresponsive" },
{ EB_ErrorDestroyMutexFailed, AVERROR_EXTERNAL, "failed to destroy mutex" },
{ EB_NoErrorEmptyQueue, AVERROR(EAGAIN), "empty queue" },
}

Referenced by svt_map_error().

◆ options

const AVOption options[]
static

Definition at line 695 of file libsvtav1.c.

◆ class_name

class_name = "libsvtav1"
private

Definition at line 742 of file libsvtav1.c.

◆ item_name

item_name = av_default_item_name
private

Definition at line 743 of file libsvtav1.c.

◆ option

option = options
private

Definition at line 744 of file libsvtav1.c.

◆ version

version = LIBAVUTIL_VERSION_INT
private

Definition at line 745 of file libsvtav1.c.

◆ @161

const { ... }

◆ eb_enc_defaults

const FFCodecDefault eb_enc_defaults[]
static
Initial value:
= {
{ "b", "0" },
{ "flags", "+cgop" },
{ "g", "-1" },
{ "qmin", "1" },
{ "qmax", "63" },
{ NULL },
}

Definition at line 748 of file libsvtav1.c.

◆ ff_libsvtav1_encoder

const FFCodec ff_libsvtav1_encoder
Initial value:
= {
.p.name = "libsvtav1",
CODEC_LONG_NAME("SVT-AV1(Scalable Video Technology for AV1) encoder"),
.priv_data_size = sizeof(SvtContext),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_AV1,
.init = eb_enc_init,
.close = eb_enc_close,
.p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
.p.priv_class = &class,
.defaults = eb_enc_defaults,
.p.wrapper_name = "libsvtav1",
}

Definition at line 757 of file libsvtav1.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
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
eb_enc_defaults
static const FFCodecDefault eb_enc_defaults[]
Definition: libsvtav1.c:748
SvtContext
Definition: libsvtav1.c:51
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:717
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
eb_receive_packet
static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: libsvtav1.c:589
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
eb_enc_init
static av_cold int eb_enc_init(AVCodecContext *avctx)
Definition: libsvtav1.c:430
eb_enc_close
static av_cold int eb_enc_close(AVCodecContext *avctx)
Definition: libsvtav1.c:672
AV_CODEC_CAP_OTHER_THREADS
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition: codec.h:124
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:284
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:326
VE
#define VE
Definition: libsvtav1.c:694
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
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
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
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
FF_CODEC_CAP_AUTO_THREADS
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: codec_internal.h:73
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299