35#define END_OF_STREAM 0x001
37#define XAVS_PART_I8X8 0x002
38#define XAVS_PART_P8X8 0x010
39#define XAVS_PART_B8X8 0x100
84 xavs_nal_t *nals,
int nnal)
94 for (
i = 0;
i < nnal;
i++)
95 size += 3U + nals[
i].i_payload;
109 for (
i = 0;
i < nnal;
i++) {
110 int size = p_end - p;
111 s = xavs_nal_encode(p, &
size, 1, nals +
i);
114 if (
s != 3U + nals[
i].i_payload)
128 xavs_picture_t pic_out;
130 x4->
pic.img.i_csp = XAVS_CSP_I420;
131 x4->
pic.img.i_plane = 3;
134 for (
i = 0;
i < 3;
i++) {
140 x4->
pic.i_type = XAVS_TYPE_AUTO;
144 if (xavs_encoder_encode(x4->
enc, &
nal, &nnal,
170 pkt->pts = pic_out.i_pts;
180 switch (pic_out.i_type) {
198 if (pic_out.i_type == XAVS_TYPE_I) {
217 xavs_encoder_close(x4->
enc);
227 xavs_param_default(&x4->
params);
230 x4->
params.p_log_private = avctx;
234 x4->
params.rc.i_rc_method = XAVS_RC_ABR;
240 x4->
params.rc.b_stat_read = 1;
243 x4->
params.rc.i_rc_method = XAVS_RC_CRF;
245 }
else if (x4->
cqp >= 0) {
246 x4->
params.rc.i_rc_method = XAVS_RC_CQP;
263 if (x4->
b_bias != INT_MIN)
302 x4->
params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16;
309 x4->
params.analyse.b_transform_8x8 = 1;
315 if (avctx->
level > 0)
319 x4->
params.rc.f_rate_tolerance =
324 x4->
params.rc.f_vbv_buffer_init =
327 x4->
params.rc.f_vbv_buffer_init = 0.9;
337 x4->
params.i_log_level = XAVS_LOG_DEBUG;
342 x4->
params.b_repeat_headers = 0;
344 x4->
enc = xavs_encoder_open(&x4->
params);
358 s = xavs_encoder_headers(x4->
enc, &
nal, &nnal);
361 for (
i = 0;
i < nnal;
i++) {
363 if (
nal[
i].i_type == NAL_SEI) {
370 size = xavs_nal_encode(p, &
s, 1,
nal +
i);
380#define OFFSET(x) offsetof(XavsContext, x)
381#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
383 {
"crf",
"Select the quality for constant quality mode",
OFFSET(crf),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE },
384 {
"qp",
"Constant quantization parameter rate control method",
OFFSET(cqp),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, INT_MAX,
VE },
385 {
"b-bias",
"Influences how often B-frames are used",
OFFSET(b_bias),
AV_OPT_TYPE_INT, {.i64 = INT_MIN}, INT_MIN, INT_MAX,
VE },
386 {
"cplxblur",
"Reduce fluctuations in QP (before curve compression)",
OFFSET(cplxblur),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE},
387 {
"direct-pred",
"Direct MV prediction mode",
OFFSET(direct_pred),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, INT_MAX,
VE, .unit =
"direct-pred" },
389 {
"spatial",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XAVS_DIRECT_PRED_SPATIAL }, 0, 0,
VE, .unit =
"direct-pred" },
390 {
"temporal",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XAVS_DIRECT_PRED_TEMPORAL }, 0, 0,
VE, .unit =
"direct-pred" },
394 {
"mixed-refs",
"One reference per partition, as opposed to one reference per macroblock",
OFFSET(mixed_refs),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1,
VE },
396 {
"motion-est",
"Set motion estimation method",
OFFSET(motion_est),
AV_OPT_TYPE_INT, { .i64 = XAVS_ME_DIA }, -1, XAVS_ME_TESA,
VE, .unit =
"motion-est"},
402 {
"b_strategy",
"Strategy to choose between I/P/B-frames",
OFFSET(b_frame_strategy),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2,
VE},
403 {
"chromaoffset",
"QP difference between chroma and luma",
OFFSET(chroma_offset),
AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX,
VE},
404 {
"sc_threshold",
"Scene change threshold",
OFFSET(scenechange_threshold),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
VE},
405 {
"noise_reduction",
"Noise reduction",
OFFSET(noise_reduction),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
VE},
411 .class_name =
"libxavs",
439 .p.wrapper_name =
"libxavs",
const FFCodec ff_libxavs_encoder
static AVFormatContext * ctx
Libavcodec external API header.
#define i(width, name, range_min, range_max)
static int FUNC aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
#define CODEC_PIXFMTS(...)
#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.
static __device__ float fabs(float a)
int(* init)(AVBSFContext *ctx)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t error[], int error_count, enum AVPictureType pict_type)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
#define AV_CODEC_FLAG_PSNR
error[?
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_NONE
Undefined.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
#define LIBAVUTIL_VERSION_INT
static const uint8_t level_map[LCEVC_LogLevelCount]
common internal API header
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
static av_cold int XAVS_close(AVCodecContext *avctx)
static const FFCodecDefault xavs_defaults[]
static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, xavs_nal_t *nals, int nnal)
static av_cold int XAVS_init(AVCodecContext *avctx)
static void XAVS_log(void *p, int level, const char *fmt, va_list args)
static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static const AVClass xavs_class
Memory handling functions.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Describe the class of an AVClass context structure.
main external API structure.
int trellis
trellis RD quantization
int max_qdiff
maximum quantizer difference between frames
int width
picture width / height.
int rc_buffer_size
decoder bitstream buffer size
int me_cmp
motion estimation comparison function
int me_subpel_quality
subpel ME quality
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
int qmin
minimum quantizer
int keyint_min
minimum GOP size
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
int64_t frame_num
Frame counter, set by libavcodec.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
int bit_rate_tolerance
number of bits the bitstream is allowed to diverge from the reference.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int level
Encoding level descriptor.
int64_t bit_rate
the average bitrate
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
int refs
number of reference frames
int64_t rc_max_rate
maximum bitrate
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int qmax
maximum quantizer
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
float qcompress
amount of qscale change between easy & hard scenes (0.0-1.0)
float qblur
amount of qscale smoothing over time (0.0-1.0)
int me_range
maximum motion estimation search range in subpel units If 0 then no limit.
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
int scenechange_threshold