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();
120 snprintf(sar,
sizeof(sar),
"%d:%d", sar_num, sar_den);
121 if (x265_param_parse(ctx->
params,
"sar", sar) == X265_PARAM_BAD_VALUE) {
130 ctx->
params->internalCsp = X265_CSP_I420;
134 ctx->
params->internalCsp = X265_CSP_I422;
138 ctx->
params->internalCsp = X265_CSP_I444;
144 ctx->
params->rc.rateControlMode = X265_RC_ABR;
148 ctx->
params->bRepeatHeaders = 1;
156 int parse_ret = x265_param_parse(ctx->
params, en->
key, en->
value);
159 case X265_PARAM_BAD_NAME:
161 "Unknown option: %s.\n", en->
key);
163 case X265_PARAM_BAD_VALUE:
165 "Invalid value for %s: %s.\n", en->
key, en->
value);
193 "Cannot allocate HEVC header of size %d.\n", avctx->
extradata_size);
205 const AVFrame *pic,
int *got_packet)
208 x265_picture x265pic;
209 x265_picture x265pic_out = { { 0 } };
217 x265_picture_init(ctx->
params, &x265pic);
220 for (i = 0; i < 3; i++) {
221 x265pic.planes[i] = pic->
data[i];
222 x265pic.stride[i] = pic->
linesize[i];
225 x265pic.pts = pic->
pts;
229 ret = x265_encoder_encode(ctx->
encoder, &nal, &nnal,
230 pic ? &x265pic : NULL, &x265pic_out);
237 for (i = 0; i < nnal; i++)
238 payload += nal[i].sizeBytes;
247 for (i = 0; i < nnal; i++) {
248 memcpy(dst, nal[i].payload, nal[i].sizeBytes);
249 dst += nal[i].sizeBytes;
255 pkt->
pts = x265pic_out.pts;
256 pkt->
dts = x265pic_out.dts;
281 if (x265_max_bit_depth == 8)
283 else if (x265_max_bit_depth == 12)
287 #define OFFSET(x) offsetof(libx265Context, x)
288 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
292 {
"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 },
318 .priv_class = &
class,