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 "codec_internal.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 FFCodecDefault eb_enc_defaults []
 
const FFCodec ff_libsvtav1_encoder
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 573 of file libsvtav1.c.

◆ VE

Definition at line 574 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 41 of file libsvtav1.c.

Function Documentation

◆ svt_map_error()

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

Definition at line 99 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 114 of file libsvtav1.c.

Referenced by eb_enc_init().

◆ alloc_buffer()

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

Definition at line 125 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 153 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 318 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 355 of file libsvtav1.c.

◆ eb_send_frame()

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

Definition at line 415 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 459 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 483 of file libsvtav1.c.

◆ eb_enc_close()

static av_cold int eb_enc_close ( AVCodecContext avctx)
static

Definition at line 554 of file libsvtav1.c.

Variable Documentation

◆ eb_err

EbErrorType eb_err

Definition at line 81 of file libsvtav1.c.

Referenced by svt_map_error().

◆ av_err

int av_err

Definition at line 82 of file libsvtav1.c.

◆ desc

const char* desc

Definition at line 83 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(), check_input_planar_rgb_to_a(), check_input_planar_rgb_to_uv(), check_input_planar_rgb_to_y(), check_output_yuv2gbrp(), choose_pixel_fmt(), chr_convert(), chr_h_scale(), chr_planar_vscale(), config_enc_params(), config_input(), config_input0(), config_input1(), 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_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_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_init2(), ff_fill_rgba_map(), ff_flac_parse_picture(), 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_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_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(), format_init(), frame_end(), gamma_convert(), 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(), 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_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(), isDataInHighBits(), isFloat(), isGray(), isNBPS(), isPacked(), isPackedRGB(), isPlanar(), isPlanarRGB(), isPlanarYUV(), isRGB(), isSemiPlanarYUV(), isSwappedChroma(), isYUV(), kmsgrab_free_desc(), kmsgrab_get_fb(), kmsgrab_read_packet(), libjxl_get_primaries(), libjxl_populate_primaries(), libopenjpeg_copy_to_packed16(), libopenjpeg_copyto16(), libopenjpeg_decode_frame(), libopenjpeg_ispacked(), libopenjpeg_matches_pix_fmt(), 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(), 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(), pix_fmt_match(), prepare_uv_scale(), print_codecs(), print_digraph(), qsv_fill_border(), qsv_init_surface(), qsv_map_from(), 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(), 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_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(), video_get_buffer(), wrap_texture_buf(), write_header(), write_packet(), xwd_encode_frame(), xyz12Torgb48(), 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 575 of file libsvtav1.c.

◆ class_name

class_name = "libsvtav1"
private

Definition at line 641 of file libsvtav1.c.

◆ item_name

item_name = av_default_item_name
private

Definition at line 642 of file libsvtav1.c.

◆ option

option = options
private

Definition at line 643 of file libsvtav1.c.

◆ version

version = LIBAVUTIL_VERSION_INT
private

Definition at line 644 of file libsvtav1.c.

◆ @90

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

◆ ff_libsvtav1_encoder

const FFCodec ff_libsvtav1_encoder
Initial value:
= {
.p.name = "libsvtav1",
.p.long_name = NULL_IF_CONFIG_SMALL("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 656 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
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:39
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:647
SvtContext
Definition: libsvtav1.c:47
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:406
eb_receive_packet
static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: libsvtav1.c:483
eb_enc_init
static av_cold int eb_enc_init(AVCodecContext *avctx)
Definition: libsvtav1.c:355
eb_enc_close
static av_cold int eb_enc_close(AVCodecContext *avctx)
Definition: libsvtav1.c:554
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:127
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_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:269
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:117
VE
#define VE
Definition: libsvtav1.c:574
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
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:82
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:70
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234