24 #define X265_API_IMPORTS 1
52 case NAL_UNIT_CODED_SLICE_BLA_W_LP:
53 case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
54 case NAL_UNIT_CODED_SLICE_BLA_N_LP:
55 case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
56 case NAL_UNIT_CODED_SLICE_IDR_N_LP:
57 case NAL_UNIT_CODED_SLICE_CRA:
70 x265_param_free(ctx->
params);
73 x265_encoder_close(ctx->
encoder);
85 "4:2:2 and 4:4:4 support is not fully defined for HEVC yet. "
86 "Set -strict experimental to encode anyway.\n");
96 ctx->
params = x265_param_alloc();
116 int sar_num, sar_den;
121 snprintf(sar,
sizeof(sar),
"%d:%d", sar_num, sar_den);
122 if (x265_param_parse(ctx->
params,
"sar", sar) == X265_PARAM_BAD_VALUE) {
131 ctx->
params->internalCsp = X265_CSP_I420;
135 ctx->
params->internalCsp = X265_CSP_I422;
139 ctx->
params->internalCsp = X265_CSP_I444;
147 if (x265_param_parse(ctx->
params,
"crf", crf) == X265_PARAM_BAD_VALUE) {
153 ctx->
params->rc.rateControlMode = X265_RC_ABR;
157 ctx->
params->bRepeatHeaders = 1;
165 int parse_ret = x265_param_parse(ctx->
params, en->
key, en->
value);
168 case X265_PARAM_BAD_NAME:
170 "Unknown option: %s.\n", en->
key);
172 case X265_PARAM_BAD_VALUE:
174 "Invalid value for %s: %s.\n", en->
key, en->
value);
205 "Cannot allocate HEVC header of size %d.\n", avctx->
extradata_size);
217 const AVFrame *pic,
int *got_packet)
220 x265_picture x265pic;
221 x265_picture x265pic_out = { { 0 } };
229 x265_picture_init(ctx->
params, &x265pic);
232 for (i = 0; i < 3; i++) {
233 x265pic.planes[i] = pic->
data[i];
234 x265pic.stride[i] = pic->
linesize[i];
237 x265pic.pts = pic->
pts;
246 ret = x265_encoder_encode(ctx->
encoder, &nal, &nnal,
247 pic ? &x265pic :
NULL, &x265pic_out);
254 for (i = 0; i < nnal; i++)
255 payload += nal[i].sizeBytes;
264 for (i = 0; i < nnal; i++) {
265 memcpy(dst, nal[i].payload, nal[i].sizeBytes);
266 dst += nal[i].sizeBytes;
272 pkt->
pts = x265pic_out.pts;
273 pkt->
dts = x265pic_out.dts;
298 if (x265_max_bit_depth == 8)
300 else if (x265_max_bit_depth == 12)
304 #define OFFSET(x) offsetof(libx265Context, x)
305 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
310 {
"x265-params",
"set the x265 configuration using a :-separated list of key=value parameters",
OFFSET(x265_opts),
AV_OPT_TYPE_STRING, { 0 }, 0, 0,
VE },
336 .priv_class = &
class,