33 #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:
71 x265_param_free(ctx->
params);
74 x265_encoder_close(ctx->
encoder);
93 "4:4:4 support is not fully defined for HEVC yet. "
94 "Set -strict experimental to encode anyway.\n");
104 ctx->
params = x265_param_alloc();
124 ctx->
params->bEnableVuiParametersPresentFlag = 1;
125 ctx->
params->bEnableAspectRatioIdc = 1;
126 ctx->
params->aspectRatioIdc = 255;
127 ctx->
params->sarWidth = sar_num;
128 ctx->
params->sarHeight = sar_den;
130 if (x265_max_bit_depth == 8)
131 ctx->
params->internalBitDepth = 8;
132 else if (x265_max_bit_depth == 12)
133 ctx->
params->internalBitDepth = 10;
138 ctx->
params->internalCsp = X265_CSP_I420;
142 ctx->
params->internalCsp = X265_CSP_I444;
148 ctx->
params->rc.rateControlMode = X265_RC_ABR;
157 int parse_ret = x265_param_parse(ctx->
params, en->
key, en->
value);
160 case X265_PARAM_BAD_NAME:
162 "Unknown option: %s.\n", en->
key);
164 case X265_PARAM_BAD_VALUE:
166 "Invalid value for %s: %s.\n", en->
key, en->
value);
183 ret = x265_encoder_headers(ctx->
encoder, &nal, &nnal);
190 for (i = 0; i < nnal; i++)
196 "Cannot allocate HEVC header of size %d.\n", ctx->
header_size);
202 for (i = 0; i < nnal; i++) {
203 memcpy(buf, nal[i].payload, nal[i].sizeBytes);
204 buf += nal[i].sizeBytes;
218 const AVFrame *pic,
int *got_packet)
221 x265_picture x265pic;
222 x265_picture x265pic_out = { { 0 } };
230 x265_picture_init(ctx->
params, &x265pic);
233 for (i = 0; i < 3; i++) {
234 x265pic.planes[i] = pic->
data[i];
235 x265pic.stride[i] = pic->
linesize[i];
238 x265pic.pts = pic->
pts;
242 ret = x265_encoder_encode(ctx->
encoder, &nal, &nnal,
243 pic ? &x265pic : NULL, &x265pic_out);
250 for (i = 0; i < nnal; i++)
251 payload += nal[i].sizeBytes;
270 for (i = 0; i < nnal; i++) {
271 memcpy(dst, nal[i].payload, nal[i].sizeBytes);
272 dst += nal[i].sizeBytes;
278 pkt->
pts = x265pic_out.pts;
279 pkt->
dts = x265pic_out.dts;
301 if (x265_max_bit_depth == 8)
303 else if (x265_max_bit_depth == 12)
307 #define OFFSET(x) offsetof(libx265Context, x)
308 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
312 {
"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 },
333 .priv_class = &
class,