35 #define END_OF_STREAM 0x001
37 #define XAVS_PART_I8X8 0x002
38 #define XAVS_PART_P8X8 0x010
39 #define XAVS_PART_B8X8 0x100
65 static const int level_map[] = {
72 if (level < 0 || level > XAVS_LOG_DEBUG)
75 av_vlog(p, level_map[level], fmt, args);
79 xavs_nal_t *nals,
int nnal)
88 for (i = 0; i < nnal; i++)
89 size += nals[i].i_payload;
102 for (i = 0; i < nnal; i++) {
103 s = xavs_nal_encode(p, &size, 1, nals + i);
119 xavs_picture_t pic_out;
121 x4->
pic.img.i_csp = XAVS_CSP_I420;
122 x4->
pic.img.i_plane = 3;
125 for (i = 0; i < 3; i++) {
126 x4->
pic.img.plane[i] = frame->
data[i];
130 x4->
pic.i_pts = frame->
pts;
131 x4->
pic.i_type = XAVS_TYPE_AUTO;
135 if (xavs_encoder_encode(x4->
enc, &nal, &nnal,
136 frame? &x4->
pic:
NULL, &pic_out) < 0)
162 pkt->
pts = pic_out.i_pts;
171 switch (pic_out.i_type) {
187 if (pic_out.i_type == XAVS_TYPE_I) {
208 xavs_encoder_close(x4->
enc);
220 xavs_param_default(&x4->
params);
223 x4->
params.p_log_private = avctx;
227 x4->
params.rc.i_rc_method = XAVS_RC_ABR;
233 x4->
params.rc.b_stat_read = 1;
236 x4->
params.rc.i_rc_method = XAVS_RC_CRF;
238 }
else if (x4->
cqp >= 0) {
239 x4->
params.rc.i_rc_method = XAVS_RC_CQP;
254 if (x4->
b_bias != INT_MIN)
293 x4->
params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16;
297 x4->
params.analyse.i_me_method = XAVS_ME_DIA;
300 x4->
params.analyse.i_me_method = XAVS_ME_HEX;
303 x4->
params.analyse.i_me_method = XAVS_ME_UMH;
306 x4->
params.analyse.i_me_method = XAVS_ME_ESA;
309 x4->
params.analyse.i_me_method = XAVS_ME_TESA;
312 x4->
params.analyse.i_me_method = XAVS_ME_HEX;
320 x4->
params.analyse.b_transform_8x8 = 1;
325 if (avctx->
level > 0)
329 x4->
params.rc.f_rate_tolerance =
334 x4->
params.rc.f_vbv_buffer_init =
337 x4->
params.rc.f_vbv_buffer_init = 0.9;
346 x4->
params.i_log_level = XAVS_LOG_DEBUG;
351 x4->
params.b_repeat_headers = 0;
353 x4->
enc = xavs_encoder_open(&x4->
params);
368 int nnal,
s, i,
size;
371 s = xavs_encoder_headers(x4->
enc, &nal, &nnal);
374 for (i = 0; i < nnal; i++) {
376 if (nal[i].i_type ==
NAL_SEI) {
378 if (xavs_nal_encode(x4->
sei, &x4->
sei_size, 1, nal + i) < 0)
383 size = xavs_nal_encode(p, &s, 1, nal + i);
393 #define OFFSET(x) offsetof(XavsContext, x)
394 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
396 {
"crf",
"Select the quality for constant quality mode",
OFFSET(crf),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE },
397 {
"qp",
"Constant quantization parameter rate control method",
OFFSET(cqp),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, INT_MAX,
VE },
398 {
"b-bias",
"Influences how often B-frames are used",
OFFSET(b_bias),
AV_OPT_TYPE_INT, {.i64 = INT_MIN}, INT_MIN, INT_MAX,
VE },
399 {
"cplxblur",
"Reduce fluctuations in QP (before curve compression)",
OFFSET(cplxblur),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE},
400 {
"direct-pred",
"Direct MV prediction mode",
OFFSET(direct_pred),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, INT_MAX,
VE,
"direct-pred" },
407 {
"mixed-refs",
"One reference per partition, as opposed to one reference per macroblock",
OFFSET(mixed_refs),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1,
VE },