Lines Matching refs:avctx
111 static int get_stats(AVCodecContext *avctx, int eos)
113 librav1eContext *ctx = avctx->priv_data;
134 avctx->stats_out = av_malloc(b64_size);
135 if (!avctx->stats_out) {
140 av_base64_encode(avctx->stats_out, b64_size, ctx->pass_data, ctx->pass_pos);
150 static int set_stats(AVCodecContext *avctx)
152 librav1eContext *ctx = avctx->priv_data;
165 static av_cold int librav1e_encode_close(AVCodecContext *avctx)
167 librav1eContext *ctx = avctx->priv_data;
185 static av_cold int librav1e_encode_init(AVCodecContext *avctx)
187 librav1eContext *ctx = avctx->priv_data;
188 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
199 av_log(avctx, AV_LOG_ERROR, "Could not allocate rav1e config.\n");
208 if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
210 avctx->framerate.den, avctx->framerate.num
214 avctx->time_base.num * avctx->ticks_per_frame,
215 avctx->time_base.den
219 if ((avctx->flags & AV_CODEC_FLAG_PASS1 || avctx->flags & AV_CODEC_FLAG_PASS2) && !avctx->bit_rate) {
220 av_log(avctx, AV_LOG_ERROR, "A bitrate must be set to use two pass mode.\n");
225 if (avctx->flags & AV_CODEC_FLAG_PASS2) {
226 if (!avctx->stats_in) {
227 av_log(avctx, AV_LOG_ERROR, "No stats file provided for second pass.\n");
232 ctx->pass_size = (strlen(avctx->stats_in) * 3) / 4;
235 av_log(avctx, AV_LOG_ERROR, "Could not allocate stats buffer.\n");
240 ctx->pass_size = av_base64_decode(ctx->pass_data, avctx->stats_in, ctx->pass_size);
242 av_log(avctx, AV_LOG_ERROR, "Invalid pass file.\n");
248 if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
253 av_log(avctx, AV_LOG_ERROR, "extract_extradata bitstream filter "
265 bret = avcodec_parameters_from_context(ctx->bsf->par_in, avctx);
283 av_log(avctx, AV_LOG_WARNING, "Invalid value for %s: %s.\n", en->key, en->value);
287 rret = rav1e_config_parse_int(cfg, "width", avctx->width);
289 av_log(avctx, AV_LOG_ERROR, "Invalid width passed to rav1e.\n");
294 rret = rav1e_config_parse_int(cfg, "height", avctx->height);
296 av_log(avctx, AV_LOG_ERROR, "Invalid height passed to rav1e.\n");
301 rret = rav1e_config_parse_int(cfg, "threads", avctx->thread_count);
303 av_log(avctx, AV_LOG_WARNING, "Invalid number of threads, defaulting to auto.\n");
308 av_log(avctx, AV_LOG_ERROR, "Could not set speed preset.\n");
318 av_log(avctx, AV_LOG_ERROR, "Could not set number of tiles to encode with.\n");
326 av_log(avctx, AV_LOG_ERROR, "Could not set number of tile rows to encode with.\n");
334 av_log(avctx, AV_LOG_ERROR, "Could not set number of tile cols to encode with.\n");
340 if (avctx->gop_size > 0) {
341 rret = rav1e_config_parse_int(cfg, "key_frame_interval", avctx->gop_size);
343 av_log(avctx, AV_LOG_ERROR, "Could not set max keyint.\n");
349 if (avctx->keyint_min > 0) {
350 rret = rav1e_config_parse_int(cfg, "min_key_frame_interval", avctx->keyint_min);
352 av_log(avctx, AV_LOG_ERROR, "Could not set min keyint.\n");
358 if (avctx->bit_rate && ctx->quantizer < 0) {
359 int max_quantizer = avctx->qmax >= 0 ? avctx->qmax : 255;
363 av_log(avctx, AV_LOG_ERROR, "Could not set max quantizer.\n");
368 if (avctx->qmin >= 0) {
369 rret = rav1e_config_parse_int(cfg, "min_quantizer", avctx->qmin);
371 av_log(avctx, AV_LOG_ERROR, "Could not set min quantizer.\n");
377 rret = rav1e_config_parse_int(cfg, "bitrate", avctx->bit_rate);
379 av_log(avctx, AV_LOG_ERROR, "Could not set bitrate.\n");
384 if (avctx->bit_rate)
385 av_log(avctx, AV_LOG_WARNING, "Both bitrate and quantizer specified. Using quantizer mode.");
389 av_log(avctx, AV_LOG_ERROR, "Could not set quantizer.\n");
396 pix_fmt_map(avctx->pix_fmt),
397 chroma_loc_map(avctx->chroma_sample_location),
398 range_map(avctx->pix_fmt, avctx->color_range));
400 av_log(avctx, AV_LOG_ERROR, "Failed to set pixel format properties.\n");
406 rret = rav1e_config_set_color_description(cfg, (RaMatrixCoefficients) avctx->colorspace,
407 (RaColorPrimaries) avctx->color_primaries,
408 (RaTransferCharacteristics) avctx->color_trc);
410 av_log(avctx, AV_LOG_WARNING, "Failed to set color properties.\n");
411 if (avctx->err_recognition & AV_EF_EXPLODE) {
419 av_log(avctx, AV_LOG_ERROR, "Failed to create rav1e encode context.\n");
433 static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
435 librav1eContext *ctx = avctx->priv_data;
443 ret = ff_encode_get_frame(avctx, frame);
452 av_log(avctx, AV_LOG_ERROR, "Could not allocate PTS buffer.\n");
459 av_log(avctx, AV_LOG_ERROR, "Could not allocate new rav1e frame.\n");
491 av_log(avctx, AV_LOG_ERROR, "Could not send frame: %s\n", rav1e_status_to_str(ret));
494 av_log(avctx, AV_LOG_ERROR, "Unknown return code %d from rav1e_send_frame: %s\n", ret, rav1e_status_to_str(ret));
500 if (avctx->flags & AV_CODEC_FLAG_PASS1) {
501 int sret = get_stats(avctx, 0);
504 } else if (avctx->flags & AV_CODEC_FLAG_PASS2) {
505 int sret = set_stats(avctx);
515 if (avctx->flags & AV_CODEC_FLAG_PASS1) {
516 int sret = get_stats(avctx, 1);
524 if (avctx->internal->draining) {
525 av_log(avctx, AV_LOG_ERROR, "Unexpected error when receiving packet after EOF.\n");
530 av_log(avctx, AV_LOG_ERROR, "Could not encode frame: %s\n", rav1e_status_to_str(ret));
533 av_log(avctx, AV_LOG_ERROR, "Unknown return code %d from rav1e_receive_packet: %s\n", ret, rav1e_status_to_str(ret));
537 ret = ff_get_encode_buffer(avctx, pkt, rpkt->len, 0);
539 av_log(avctx, AV_LOG_ERROR, "Could not allocate packet.\n");
553 if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
556 av_log(avctx, AV_LOG_ERROR, "extradata extraction send failed.\n");
563 av_log(avctx, AV_LOG_ERROR, "extradata extraction receive failed.\n");