Lines Matching defs:avctx

150                              AVCodecContext *avctx)
152 SvtContext *svt_enc = avctx->priv_data;
171 if (avctx->bit_rate) {
172 param->target_bit_rate = avctx->bit_rate;
173 if (avctx->rc_max_rate != avctx->bit_rate)
178 param->max_qp_allowed = avctx->qmax;
179 param->min_qp_allowed = avctx->qmin;
181 param->max_bit_rate = avctx->rc_max_rate;
182 if ((avctx->bit_rate > 0 || avctx->rc_max_rate > 0) && avctx->rc_buffer_size)
184 avctx->rc_buffer_size * 1000LL /
185 FFMAX(avctx->bit_rate, avctx->rc_max_rate);
196 desc = av_pix_fmt_desc_get(avctx->pix_fmt);
197 param->color_primaries = avctx->color_primaries;
199 AVCOL_SPC_RGB : avctx->colorspace;
200 param->transfer_characteristics = avctx->color_trc;
202 if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED)
203 param->color_range = avctx->color_range == AVCOL_RANGE_JPEG;
208 if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) {
210 av_chroma_location_name(avctx->chroma_sample_location);
212 switch (avctx->chroma_sample_location) {
223 av_log(avctx, AV_LOG_WARNING,
234 if (avctx->profile != FF_PROFILE_UNKNOWN)
235 param->profile = avctx->profile;
237 if (avctx->level != FF_LEVEL_UNKNOWN)
238 param->level = avctx->level;
240 if (avctx->gop_size > 0)
241 param->intra_period_length = avctx->gop_size - 1;
243 if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
244 param->frame_rate_numerator = avctx->framerate.num;
245 param->frame_rate_denominator = avctx->framerate.den;
247 param->frame_rate_numerator = avctx->time_base.den;
248 param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
252 param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1;
258 int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
259 av_log(avctx, level, "Error parsing option %s: %s.\n", en->key, en->value);
260 if (avctx->err_recognition & AV_EF_EXPLODE)
266 int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
267 av_log(avctx, level, "svt-params needs libavcodec to be compiled with SVT-AV1 "
269 if (avctx->err_recognition & AV_EF_EXPLODE)
274 param->source_width = avctx->width;
275 param->source_height = avctx->height;
286 av_log(avctx, AV_LOG_ERROR , "Unsupported pixel format\n");
292 av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n");
295 av_log(avctx, AV_LOG_WARNING, "Forcing High profile\n");
299 avctx->bit_rate = param->rate_control_mode > 0 ?
301 avctx->rc_max_rate = param->max_bit_rate;
302 avctx->rc_buffer_size = param->maximum_buffer_size_ms *
303 FFMAX(avctx->bit_rate, avctx->rc_max_rate) / 1000LL;
305 if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) {
306 AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx);
310 cpb_props->buffer_size = avctx->rc_buffer_size;
311 cpb_props->max_bitrate = avctx->rc_max_rate;
312 cpb_props->avg_bitrate = avctx->bit_rate;
355 static av_cold int eb_enc_init(AVCodecContext *avctx)
357 SvtContext *svt_enc = avctx->priv_data;
365 return svt_print_error(avctx, svt_ret, "Error initializing encoder handle");
368 ret = config_enc_params(&svt_enc->enc_params, avctx);
370 av_log(avctx, AV_LOG_ERROR, "Error configuring encoder parameters\n");
376 return svt_print_error(avctx, svt_ret, "Error setting encoder parameters");
381 return svt_print_error(avctx, svt_ret, "Error initializing encoder");
384 if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
389 return svt_print_error(avctx, svt_ret, "Error building stream header");
392 avctx->extradata_size = headerPtr->n_filled_len;
393 avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
394 if (!avctx->extradata) {
395 av_log(avctx, AV_LOG_ERROR,
396 "Cannot allocate AV1 header of size %d.\n", avctx->extradata_size);
400 memcpy(avctx->extradata, headerPtr->p_buffer, avctx->extradata_size);
404 return svt_print_error(avctx, svt_ret, "Error freeing stream header");
415 static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame)
417 SvtContext *svt_enc = avctx->priv_data;
459 static AVBufferRef *get_output_ref(AVCodecContext *avctx, SvtContext *svt_enc, int filled_len)
466 av_log(avctx, AV_LOG_ERROR, "TU size > %d raw frame size.\n", max_frames);
483 static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
485 SvtContext *svt_enc = avctx->priv_data;
495 ret = ff_encode_get_frame(avctx, frame);
501 ret = eb_send_frame(avctx, frame);
510 ref = get_output_ref(avctx, svt_enc, headerPtr->n_filled_len);
512 av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
554 static av_cold int eb_enc_close(AVCodecContext *avctx)
556 SvtContext *svt_enc = avctx->priv_data;
596 { .i64 = value }, 0, 0, VE, "avctx.level"