Lines Matching defs:ctx

84     libx265Context *ctx = avctx->priv_data;
86 ctx->api->param_free(ctx->params);
87 av_freep(&ctx->sei_data);
89 if (ctx->encoder)
90 ctx->api->encoder_close(ctx->encoder);
98 libx265Context *ctx = avctx->priv_data;
102 if (ctx->api->param_parse(ctx->params, key, buf) == X265_PARAM_BAD_VALUE) {
113 libx265Context *ctx = avctx->priv_data;
117 if (ctx->api->param_parse(ctx->params, key, buf) == X265_PARAM_BAD_VALUE) {
127 libx265Context *ctx = avctx->priv_data;
132 ctx->api = x265_api_get(desc->comp[0].depth);
133 if (!ctx->api)
134 ctx->api = x265_api_get(0);
136 ctx->params = ctx->api->param_alloc();
137 if (!ctx->params) {
142 if (ctx->api->param_default_preset(ctx->params, ctx->preset, ctx->tune) < 0) {
145 av_log(avctx, AV_LOG_ERROR, "Error setting preset/tune %s/%s.\n", ctx->preset, ctx->tune);
160 ctx->params->frameNumThreads = avctx->thread_count;
162 ctx->params->fpsNum = avctx->framerate.num;
163 ctx->params->fpsDenom = avctx->framerate.den;
165 ctx->params->fpsNum = avctx->time_base.den;
166 ctx->params->fpsDenom = avctx->time_base.num * avctx->ticks_per_frame;
168 ctx->params->sourceWidth = avctx->width;
169 ctx->params->sourceHeight = avctx->height;
170 ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR);
171 ctx->params->bOpenGOP = !(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP);
174 if (ctx->params->sourceWidth < 64 || ctx->params->sourceHeight < 64)
175 ctx->params->maxCUSize = 32;
176 if (ctx->params->sourceWidth < 32 || ctx->params->sourceHeight < 32)
177 ctx->params->maxCUSize = 16;
178 if (ctx->params->sourceWidth < 16 || ctx->params->sourceHeight < 16) {
180 ctx->params->sourceWidth, ctx->params->sourceHeight);
185 ctx->params->vui.bEnableVideoSignalTypePresentFlag = 1;
188 ctx->params->vui.bEnableVideoFullRangeFlag =
191 ctx->params->vui.bEnableVideoFullRangeFlag =
204 ctx->params->vui.bEnableColorDescriptionPresentFlag = 1;
207 ctx->params->vui.colorPrimaries = avctx->color_primaries;
208 ctx->params->vui.transferCharacteristics = avctx->color_trc;
211 ctx->params->preferredTransferCharacteristics = ctx->params->vui.transferCharacteristics;
213 ctx->params->vui.matrixCoeffs = avctx->colorspace;
219 ctx->params->vui.bEnableChromaLocInfoPresentFlag =
223 if (ctx->params->vui.bEnableChromaLocInfoPresentFlag) {
224 ctx->params->vui.chromaSampleLocTypeTopField =
225 ctx->params->vui.chromaSampleLocTypeBottomField =
237 if (ctx->api->param_parse(ctx->params, "sar", sar) == X265_PARAM_BAD_VALUE) {
248 if (ctx->api->api_build_number < 85) {
251 ctx->api->api_build_number);
254 ctx->params->internalCsp = X265_CSP_I400;
260 ctx->params->vui.matrixCoeffs = AVCOL_SPC_RGB;
261 ctx->params->vui.bEnableVideoSignalTypePresentFlag = 1;
262 ctx->params->vui.bEnableColorDescriptionPresentFlag = 1;
265 ctx->params->internalCsp = X265_CSP_I444;
269 ctx->params->internalCsp = desc->log2_chroma_h == 1 ?
279 if (ctx->crf >= 0) {
282 snprintf(crf, sizeof(crf), "%2.2f", ctx->crf);
283 if (ctx->api->param_parse(ctx->params, "crf", crf) == X265_PARAM_BAD_VALUE) {
284 av_log(avctx, AV_LOG_ERROR, "Invalid crf: %2.2f.\n", ctx->crf);
288 ctx->params->rc.bitrate = avctx->bit_rate / 1000;
289 ctx->params->rc.rateControlMode = X265_RC_ABR;
290 } else if (ctx->cqp >= 0) {
291 ret = libx265_param_parse_int(avctx, "qp", ctx->cqp);
334 ctx->params->rc.vbvBufferSize = avctx->rc_buffer_size / 1000;
335 ctx->params->rc.vbvMaxBitrate = avctx->rc_max_rate / 1000;
340 cpb_props->buffer_size = ctx->params->rc.vbvBufferSize * 1000;
341 cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000LL;
342 cpb_props->avg_bitrate = ctx->params->rc.bitrate * 1000LL;
345 ctx->params->bRepeatHeaders = 1;
370 while ((en = av_dict_get(ctx->x265_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
371 int parse_ret = ctx->api->param_parse(ctx->params, en->key, en->value);
388 if (ctx->params->rc.vbvBufferSize && avctx->rc_initial_buffer_occupancy > 1000 &&
389 ctx->params->rc.vbvBufferInit == 0.9) {
390 ctx->params->rc.vbvBufferInit = (float)avctx->rc_initial_buffer_occupancy / 1000;
393 if (ctx->profile) {
394 if (ctx->api->param_apply_profile(ctx->params, ctx->profile) < 0) {
396 av_log(avctx, AV_LOG_ERROR, "Invalid or incompatible profile set: %s.\n", ctx->profile);
405 ctx->encoder = ctx->api->encoder_open(ctx->params);
406 if (!ctx->encoder) {
416 avctx->extradata_size = ctx->api->encoder_headers(ctx->encoder, &nal, &nnal);
438 static av_cold int libx265_encode_set_roi(libx265Context *ctx, const AVFrame *frame, x265_picture* pic)
442 if (ctx->params->rc.aqMode == X265_AQ_NONE) {
443 if (!ctx->roi_warned) {
444 ctx->roi_warned = 1;
445 av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
449 int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;
461 av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n");
485 av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must not be zero.\n");
505 libx265Context *ctx = avctx->priv_data;
516 ctx->api->picture_init(ctx->params, &x265pic);
530 (ctx->forced_idr ? X265_TYPE_IDR : X265_TYPE_I) :
535 ret = libx265_encode_set_roi(ctx, pic, &x265pic);
549 if (ctx->udu_sei) {
558 tmp = av_fast_realloc(ctx->sei_data,
559 &ctx->sei_data_size,
566 ctx->sei_data = tmp;
567 sei->payloads = ctx->sei_data;
578 ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal,