35 #define END_OF_STREAM 0x001
37 #define XAVS_PART_I8X8 0x002
38 #define XAVS_PART_P8X8 0x010
39 #define XAVS_PART_B8X8 0x100
66 static const int level_map[] = {
73 if (level < 0 || level > XAVS_LOG_DEBUG)
76 av_vlog(p, level_map[level], fmt, args);
80 xavs_nal_t *nals,
int nnal)
89 for (i = 0; i < nnal; i++)
90 size += nals[i].i_payload;
103 for (i = 0; i < nnal; i++) {
104 s = xavs_nal_encode(p, &size, 1, nals + i);
120 xavs_picture_t pic_out;
122 x4->
pic.img.i_csp = XAVS_CSP_I420;
123 x4->
pic.img.i_plane = 3;
126 for (i = 0; i < 3; i++) {
127 x4->
pic.img.plane[i] = frame->
data[i];
131 x4->
pic.i_pts = frame->
pts;
132 x4->
pic.i_type = XAVS_TYPE_AUTO;
136 if (xavs_encoder_encode(x4->
enc, &nal, &nnal,
137 frame? &x4->
pic:
NULL, &pic_out) < 0)
163 pkt->
pts = pic_out.i_pts;
172 switch (pic_out.i_type) {
188 if (pic_out.i_type == XAVS_TYPE_I) {
209 xavs_encoder_close(x4->
enc);
219 xavs_param_default(&x4->
params);
222 x4->
params.p_log_private = avctx;
226 x4->
params.rc.i_rc_method = XAVS_RC_ABR;
232 x4->
params.rc.b_stat_read = 1;
235 x4->
params.rc.i_rc_method = XAVS_RC_CRF;
237 }
else if (x4->
cqp >= 0) {
238 x4->
params.rc.i_rc_method = XAVS_RC_CQP;
253 if (x4->
b_bias != INT_MIN)
292 x4->
params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16;
296 x4->
params.analyse.i_me_method = XAVS_ME_DIA;
299 x4->
params.analyse.i_me_method = XAVS_ME_HEX;
302 x4->
params.analyse.i_me_method = XAVS_ME_UMH;
305 x4->
params.analyse.i_me_method = XAVS_ME_ESA;
308 x4->
params.analyse.i_me_method = XAVS_ME_TESA;
311 x4->
params.analyse.i_me_method = XAVS_ME_HEX;
319 x4->
params.analyse.b_transform_8x8 = 1;
324 if (avctx->
level > 0)
327 x4->
params.rc.f_rate_tolerance =
332 x4->
params.rc.f_vbv_buffer_init =
335 x4->
params.rc.f_vbv_buffer_init = 0.9;
344 x4->
params.i_log_level = XAVS_LOG_DEBUG;
349 x4->
params.b_repeat_headers = 0;
351 x4->
enc = xavs_encoder_open(&x4->
params);
363 int nnal, s, i,
size;
366 s = xavs_encoder_headers(x4->
enc, &nal, &nnal);
369 for (i = 0; i < nnal; i++) {
371 if (nal[i].i_type ==
NAL_SEI) {
373 if (xavs_nal_encode(x4->
sei, &x4->
sei_size, 1, nal + i) < 0)
378 size = xavs_nal_encode(p, &s, 1, nal + i);
388 #define OFFSET(x) offsetof(XavsContext, x)
389 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
391 {
"crf",
"Select the quality for constant quality mode",
OFFSET(crf),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE },
392 {
"qp",
"Constant quantization parameter rate control method",
OFFSET(cqp),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, INT_MAX,
VE },
393 {
"b-bias",
"Influences how often B-frames are used",
OFFSET(b_bias),
AV_OPT_TYPE_INT, {.i64 = INT_MIN}, INT_MIN, INT_MAX,
VE },
394 {
"cplxblur",
"Reduce fluctuations in QP (before curve compression)",
OFFSET(cplxblur),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE},
395 {
"direct-pred",
"Direct MV prediction mode",
OFFSET(direct_pred),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, INT_MAX,
VE,
"direct-pred" },
402 {
"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 },
430 .priv_class = &
class,