FFmpeg
Loading...
Searching...
No Matches
libx265.c File Reference
#include <x265.h>
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/buffer.h"
#include "libavutil/internal.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "dovi_rpu.h"
#include "encode.h"
#include "atsc_a53.h"
#include "sei.h"

Go to the source code of this file.

Data Structures

struct  ReorderedData
 
struct  libx265Context
 

Macros

#define FF_X265_MAX_LAYERS   1
 
#define OFFSET(x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static int is_keyframe (NalUnitType naltype)
 
static int rd_get (libx265Context *ctx)
 
static void rd_release (libx265Context *ctx, int idx)
 
static av_cold int libx265_encode_close (AVCodecContext *avctx)
 
static av_cold int libx265_param_parse_float (AVCodecContext *avctx, const char *key, float value)
 
static av_cold int libx265_param_parse_int (AVCodecContext *avctx, const char *key, int value)
 
static int handle_mdcv (void *logctx, const x265_api *api, x265_param *params, const AVMasteringDisplayMetadata *mdcv)
 
static int handle_side_data (AVCodecContext *avctx, const x265_api *api, x265_param *params)
 
static int get_x265_log_level (AVCodecContext *avctx)
 
static av_cold int libx265_encode_init (AVCodecContext *avctx)
 
static av_cold int libx265_encode_set_roi (libx265Context *ctx, const AVFrame *frame, x265_picture *pic)
 
static void free_picture (libx265Context *ctx, x265_picture *pic)
 
static int libx265_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet)
 
static int libx265_get_supported_config (const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
 

Variables

static enum AVPixelFormat x265_csp_eight []
 
static enum AVPixelFormat x265_csp_ten []
 
static enum AVPixelFormat x265_csp_twelve []
 
static const AVOption options []
 
class { 
 
      class_name = "libx265" 
 
      item_name = av_default_item_name 
 
      option = options 
 
      version = LIBAVUTIL_VERSION_INT 
 
};  
 
static const FFCodecDefault x265_defaults []
 
const FFCodec ff_libx265_encoder
 

Macro Definition Documentation

◆ FF_X265_MAX_LAYERS

#define FF_X265_MAX_LAYERS   1

Definition at line 49 of file libx265.c.

Referenced by libx265_encode_frame().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 1041 of file libx265.c.

◆ VE

Definition at line 1042 of file libx265.c.

Function Documentation

◆ is_keyframe()

static int is_keyframe ( NalUnitType naltype)
static

◆ rd_get()

static int rd_get ( libx265Context * ctx)
static

Definition at line 109 of file libx265.c.

Referenced by libx265_encode_frame().

◆ rd_release()

static void rd_release ( libx265Context * ctx,
int idx )
static

Definition at line 136 of file libx265.c.

Referenced by free_picture(), libx265_encode_close(), and libx265_encode_frame().

◆ libx265_encode_close()

static av_cold int libx265_encode_close ( AVCodecContext * avctx)
static

Definition at line 143 of file libx265.c.

Referenced by libx265_encode_init().

◆ libx265_param_parse_float()

static av_cold int libx265_param_parse_float ( AVCodecContext * avctx,
const char * key,
float value )
static

Definition at line 162 of file libx265.c.

Referenced by libx265_encode_init().

◆ libx265_param_parse_int()

static av_cold int libx265_param_parse_int ( AVCodecContext * avctx,
const char * key,
int value )
static

Definition at line 177 of file libx265.c.

Referenced by libx265_encode_init().

◆ handle_mdcv()

static int handle_mdcv ( void * logctx,
const x265_api * api,
x265_param * params,
const AVMasteringDisplayMetadata * mdcv )
static

Definition at line 192 of file libx265.c.

Referenced by handle_side_data().

◆ handle_side_data()

static int handle_side_data ( AVCodecContext * avctx,
const x265_api * api,
x265_param * params )
static

Definition at line 224 of file libx265.c.

Referenced by libx265_encode_init().

◆ get_x265_log_level()

static int get_x265_log_level ( AVCodecContext * avctx)
static

Definition at line 254 of file libx265.c.

Referenced by libx265_encode_init().

◆ libx265_encode_init()

static av_cold int libx265_encode_init ( AVCodecContext * avctx)
static

Definition at line 272 of file libx265.c.

◆ libx265_encode_set_roi()

static av_cold int libx265_encode_set_roi ( libx265Context * ctx,
const AVFrame * frame,
x265_picture * pic )
static

Definition at line 637 of file libx265.c.

Referenced by libx265_encode_frame().

◆ free_picture()

static void free_picture ( libx265Context * ctx,
x265_picture * pic )
static

Definition at line 701 of file libx265.c.

Referenced by libx265_encode_frame().

◆ libx265_encode_frame()

static int libx265_encode_frame ( AVCodecContext * avctx,
AVPacket * pkt,
const AVFrame * pic,
int * got_packet )
static

Definition at line 721 of file libx265.c.

◆ libx265_get_supported_config()

static int libx265_get_supported_config ( const AVCodecContext * avctx,
const AVCodec * codec,
enum AVCodecConfig config,
unsigned flags,
const void ** out,
int * out_num )
static

Definition at line 1017 of file libx265.c.

Variable Documentation

◆ x265_csp_eight

enum AVPixelFormat x265_csp_eight[]
static
Initial value:
= {
}
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85

Definition at line 955 of file libx265.c.

Referenced by libx265_get_supported_config().

◆ x265_csp_ten

enum AVPixelFormat x265_csp_ten[]
static

◆ x265_csp_twelve

◆ options

const AVOption options[]
static
Initial value:
= {
{ "crf", "set the x265 crf", OFFSET(crf), AV_OPT_TYPE_FLOAT, { .dbl = -1 }, -1, FLT_MAX, VE },
{ "qp", "set the x265 qp", OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
{ "forced-idr", "if forcing keyframes, force them as IDR frames", OFFSET(forced_idr),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "preset", "set the x265 preset", OFFSET(preset), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ "tune", "set the x265 tune parameter", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ "profile", "set the x265 profile", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ "x265-stats", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ "udu_sei", "Use user data unregistered SEI if available", OFFSET(udu_sei), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
{ NULL }
}
#define VE
Definition amfenc_av1.c:30
#define NULL
Definition coverity.c:32
static CheckasmStats stats
Definition checkasm.c:75
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
Definition opt.h:289
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
int profile
Definition mxfenc.c:2299
preset
Definition vf_curves.c:47

Definition at line 1043 of file libx265.c.

◆ class_name

class_name = "libx265"
private

Definition at line 1062 of file libx265.c.

◆ item_name

item_name = av_default_item_name
private

Definition at line 1063 of file libx265.c.

◆ option

option = options
private

Definition at line 1064 of file libx265.c.

◆ version

version = LIBAVUTIL_VERSION_INT
private

Definition at line 1065 of file libx265.c.

◆ [class]

const AVClass class { ... }

◆ x265_defaults

const FFCodecDefault x265_defaults[]
static
Initial value:
= {
{ "b", "0" },
{ "bf", "-1" },
{ "g", "-1" },
{ "keyint_min", "-1" },
{ "refs", "-1" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "qdiff", "-1" },
{ "qblur", "-1" },
{ "qcomp", "-1" },
{ "i_qfactor", "-1" },
{ "b_qfactor", "-1" },
{ NULL },
}

Definition at line 1068 of file libx265.c.

◆ ff_libx265_encoder

const FFCodec ff_libx265_encoder
Initial value:
= {
.p.name = "libx265",
CODEC_LONG_NAME("libx265 H.265 / HEVC"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
.p.priv_class = &class,
.p.wrapper_name = "libx265",
.get_supported_config = libx265_get_supported_config,
.priv_data_size = sizeof(libx265Context),
}
static const FFCodecDefault defaults[]
Definition amfenc_av1.c:723
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
#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_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition codec.h:112
#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
@ AV_CODEC_ID_HEVC
Definition codec_id.h:223
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet)
Definition libx265.c:721
static av_cold int libx265_encode_init(AVCodecContext *avctx)
Definition libx265.c:272
static av_cold int libx265_encode_close(AVCodecContext *avctx)
Definition libx265.c:143
static const FFCodecDefault x265_defaults[]
Definition libx265.c:1068
static int libx265_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
Definition libx265.c:1017
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:783

Definition at line 1084 of file libx265.c.