24 #define X265_API_IMPORTS 1
50 case NAL_UNIT_CODED_SLICE_BLA_W_LP:
51 case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
52 case NAL_UNIT_CODED_SLICE_BLA_N_LP:
53 case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
54 case NAL_UNIT_CODED_SLICE_IDR_N_LP:
55 case NAL_UNIT_CODED_SLICE_CRA:
68 x265_param_free(ctx->
params);
71 x265_encoder_close(ctx->
encoder);
87 "4:2:2 and 4:4:4 support is not fully defined for HEVC yet. "
88 "Set -strict experimental to encode anyway.\n");
98 ctx->
params = x265_param_alloc();
119 snprintf(sar,
sizeof(sar),
"%d:%d", sar_num, sar_den);
120 if (x265_param_parse(ctx->
params,
"sar", sar) == X265_PARAM_BAD_VALUE) {
129 ctx->
params->internalCsp = X265_CSP_I420;
133 ctx->
params->internalCsp = X265_CSP_I422;
137 ctx->
params->internalCsp = X265_CSP_I444;
143 ctx->
params->rc.rateControlMode = X265_RC_ABR;
147 ctx->
params->bRepeatHeaders = 1;
155 int parse_ret = x265_param_parse(ctx->
params, en->
key, en->
value);
158 case X265_PARAM_BAD_NAME:
160 "Unknown option: %s.\n", en->
key);
162 case X265_PARAM_BAD_VALUE:
164 "Invalid value for %s: %s.\n", en->
key, en->
value);
192 "Cannot allocate HEVC header of size %d.\n", avctx->
extradata_size);
204 const AVFrame *pic,
int *got_packet)
207 x265_picture x265pic;
208 x265_picture x265pic_out = { { 0 } };
216 x265_picture_init(ctx->
params, &x265pic);
219 for (i = 0; i < 3; i++) {
220 x265pic.planes[i] = pic->
data[i];
221 x265pic.stride[i] = pic->
linesize[i];
224 x265pic.pts = pic->
pts;
228 ret = x265_encoder_encode(ctx->
encoder, &nal, &nnal,
229 pic ? &x265pic : NULL, &x265pic_out);
236 for (i = 0; i < nnal; i++)
237 payload += nal[i].sizeBytes;
246 for (i = 0; i < nnal; i++) {
247 memcpy(dst, nal[i].payload, nal[i].sizeBytes);
248 dst += nal[i].sizeBytes;
254 pkt->
pts = x265pic_out.pts;
255 pkt->
dts = x265pic_out.dts;
280 if (x265_max_bit_depth == 8)
282 else if (x265_max_bit_depth == 12)
286 #define OFFSET(x) offsetof(libx265Context, x)
287 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
291 {
"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 },
312 .priv_class = &
class,