FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
libsvtav1.c File Reference
#include <stdint.h>
#include <EbSvtAv1ErrorCodes.h>
#include <EbSvtAv1Enc.h>
#include "libavutil/common.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avassert.h"
#include "internal.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 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 AVCodecDefault eb_enc_defaults []
 
const AVCodec ff_libsvtav1_encoder
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 472 of file libsvtav1.c.

◆ VE

Definition at line 473 of file libsvtav1.c.

◆ LEVEL

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

Enumeration Type Documentation

◆ eos_status

enum eos_status
Enumerator
EOS_NOT_REACHED 
EOS_SENT 
EOS_RECEIVED 

Definition at line 40 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().

◆ 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().

◆ config_enc_params()

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

Definition at line 149 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 224 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 261 of file libsvtav1.c.

◆ eb_send_frame()

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

Definition at line 321 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 358 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 382 of file libsvtav1.c.

◆ eb_enc_close()

static av_cold int eb_enc_close ( AVCodecContext avctx)
static

Definition at line 453 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 any_vscale(), aom_init(), asf_read_picture(), asf_write_header1(), av_bsf_init(), av_frame_apply_cropping(), av_image_alloc(), av_image_copy_to_buffer(), av_image_fill_black(), 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(), calc_cropping_offsets(), cbs_clone_unit_content(), cbs_default_free_unit_content(), cbs_find_unit_type_desc(), check_image_pointers(), choose_pixel_fmt(), chr_convert(), chr_h_scale(), chr_planar_vscale(), config_enc_params(), config_input(), config_input0(), config_input1(), config_input_main(), config_input_ref(), config_inputx(), config_inputy(), config_out_props(), config_output(), config_props(), config_props_output(), copy_picture_field(), copy_uv_planes(), count_ports(), create_all_formats(), d3d11va_device_create(), d3d11va_get_buffer(), d3d11va_transfer_data(), decode(), decode_frame(), descriptor_compare(), deshake_opencl_init(), drm_map_frame(), encode_frame(), encode_init(), ff_all_formats(), ff_boxblur_eval_filter_params(), ff_cbs_alloc_unit_content2(), ff_cbs_make_unit_refcounted(), ff_cbs_make_unit_writable(), ff_cbs_sei_add_message(), ff_cbs_sei_alloc_message_payload(), ff_color_frame(), ff_draw_color(), ff_draw_horiz_band(), ff_draw_init(), ff_flac_parse_picture(), ff_formats_pixdesc_filter(), ff_frame_pool_get(), ff_frame_pool_video_init(), ff_frame_to_dnn_classify(), ff_get_format(), ff_guess_coded_bitrate(), ff_h264_draw_horiz_band(), 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_mediacodec_dec_init(), ff_scale_eval_dimensions(), ff_sws_alphablendaway(), ff_sws_init_output_funcs(), ff_vk_add_descriptor_set(), ff_vk_shader_rep_fmt(), ff_vmafmotion_init(), fill_texture_ptrs(), filter_frame(), find_codec_or_die(), flac_write_picture(), flush_encoders(), format_init(), frame_end(), gamma_convert(), geq_config_props(), get_aspect_ratio(), get_bit_depth(), get_codecs_sorted(), get_color_type(), get_deinterleaved_format(), get_format(), get_mimetype(), get_pix_fmt_depth(), get_plane_wh(), get_video_buffer(), h264_metadata_update_sps(), h265_metadata_guess_level(), handle_connect_error(), have_alpha_planar(), hScale16To15_c(), hScale16To19_c(), hwmap_config_output(), image_copy(), image_copy_16_to_8(), image_get_linesize(), init(), init_filter(), init_image(), init_muxer(), init_sec_buffer_desc(), init_video_param(), init_video_param_jpeg(), is16BPS(), is32BPS(), is_planar_yuv(), isALPHA(), isAnyRGB(), isBayer(), isBayer16BPS(), isBE(), isFloat(), isGray(), isNBPS(), isPacked(), isPackedRGB(), isPlanar(), isPlanarRGB(), isPlanarYUV(), isRGB(), isSemiPlanarYUV(), isYUV(), kmsgrab_free_desc(), kmsgrab_get_fb(), kmsgrab_read_packet(), libopenjpeg_copy_to_packed16(), libopenjpeg_copyto16(), libopenjpeg_decode_frame(), libopenjpeg_ispacked(), libopenjpeg_matches_pix_fmt(), librav1e_encode_init(), librav1e_receive_packet(), list_formats(), log_encoder_error(), lum_convert(), lum_h_scale(), lum_planar_vscale(), lut2_config_output(), main(), map_pixel_format(), message(), mj2_create_image(), nlmeans_opencl_filter_frame(), no_chr_scale(), 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(), pix_fmt_match(), prepare_uv_scale(), print_codecs(), print_digraph(), qsv_init_surface(), qsv_map_from(), query_formats(), raw_decode(), raw_encode_init(), raw_init_decoder(), read_gab2_sub(), read_packet_vs(), realign_frame(), rgb48Toxyz12(), 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(), svt_map_error(), svt_print_error(), swscale(), tiff_unpack_strip(), tonemap(), tonemap_slice(), transcode_init(), transfer_image_buf(), unsharp_opencl_make_filter_params(), unsupported_codec(), v4l2_buffer_swframe_to_buf(), v4l2_encode_init(), v4l2_read_header(), vaapi_encode_h265_init_sequence_params(), 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(), video_get_buffer(), wrap_texture_buf(), write_header(), write_packet(), xwd_encode_frame(), xyz12Torgb48(), yuv2gbrp16_full_X_c(), yuv2gbrp_full_X_c(), and yuv2gbrpf32_full_X_c().

◆ 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 474 of file libsvtav1.c.

◆ class_name

class_name = "libsvtav1"
private

Definition at line 540 of file libsvtav1.c.

◆ item_name

item_name = av_default_item_name
private

Definition at line 541 of file libsvtav1.c.

◆ option

option = options
private

Definition at line 542 of file libsvtav1.c.

◆ version

version = LIBAVUTIL_VERSION_INT
private

Definition at line 543 of file libsvtav1.c.

◆ @87

const { ... }

◆ eb_enc_defaults

const AVCodecDefault eb_enc_defaults[]
static
Initial value:
= {
{ "b", "7M" },
{ "g", "-1" },
{ "qmin", "0" },
{ "qmax", "63" },
{ NULL },
}

Definition at line 546 of file libsvtav1.c.

◆ ff_libsvtav1_encoder

const AVCodec ff_libsvtav1_encoder
Initial value:
= {
.name = "libsvtav1",
.long_name = NULL_IF_CONFIG_SMALL("SVT-AV1(Scalable Video Technology for AV1) encoder"),
.priv_data_size = sizeof(SvtContext),
.receive_packet = eb_receive_packet,
.close = eb_enc_close,
.caps_internal = FF_CODEC_CAP_AUTO_THREADS,
.priv_class = &class,
.defaults = eb_enc_defaults,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.wrapper_name = "libsvtav1",
}

Definition at line 554 of file libsvtav1.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
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
SvtContext
Definition: libsvtav1.c:46
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:389
eb_receive_packet
static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: libsvtav1.c:382
eb_enc_init
static av_cold int eb_enc_init(AVCodecContext *avctx)
Definition: libsvtav1.c:261
eb_enc_close
static av_cold int eb_enc_close(AVCodecContext *avctx)
Definition: libsvtav1.c:453
eb_enc_defaults
static const AVCodecDefault eb_enc_defaults[]
Definition: libsvtav1.c:546
type
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 type
Definition: writing_filters.txt:86
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:122
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:290
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:66
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:279
FF_CODEC_CAP_AUTO_THREADS
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: internal.h:81
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:116
VE
#define VE
Definition: libsvtav1.c:473
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:57
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: internal.h:50
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
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
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:77
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233