MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / init_enc_options

Function init_enc_options

libavcodec/vulkan_encode_av1.c:689–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687}
688
689static int init_enc_options(AVCodecContext *avctx)
690{
691 VulkanEncodeAV1Context *enc = avctx->priv_data;
692
693 if (avctx->rc_buffer_size)
694 enc->hrd_buffer_size = avctx->rc_buffer_size;
695 else if (avctx->rc_max_rate > 0)
696 enc->hrd_buffer_size = avctx->rc_max_rate;
697 else
698 enc->hrd_buffer_size = avctx->bit_rate;
699
700 if (avctx->rc_initial_buffer_occupancy) {
701 if (avctx->rc_initial_buffer_occupancy > enc->hrd_buffer_size) {
702 av_log(avctx, AV_LOG_ERROR, "Invalid RC buffer settings: "
703 "must have initial buffer size (%d) <= "
704 "buffer size (%"PRId64").\n",
705 avctx->rc_initial_buffer_occupancy, enc->hrd_buffer_size);
706 return AVERROR(EINVAL);
707 }
708 enc->initial_buffer_fullness = avctx->rc_initial_buffer_occupancy;
709 } else {
710 enc->initial_buffer_fullness = enc->hrd_buffer_size * 3 / 4;
711 }
712
713 if (enc->common.opts.rc_mode == VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR) {
714 enc->q_idx_p = av_clip(enc->common.opts.qp,
715 enc->caps.minQIndex, enc->caps.maxQIndex);
716 if (fabs(avctx->i_quant_factor) > 0.0)
717 enc->q_idx_idr =
718 av_clip((fabs(avctx->i_quant_factor) * enc->q_idx_p +
719 avctx->i_quant_offset) + 0.5,
720 0, 255);
721 else
722 enc->q_idx_idr = enc->q_idx_p;
723
724 if (fabs(avctx->b_quant_factor) > 0.0)
725 enc->q_idx_b =
726 av_clip((fabs(avctx->b_quant_factor) * enc->q_idx_p +
727 avctx->b_quant_offset) + 0.5,
728 0, 255);
729 else
730 enc->q_idx_b = enc->q_idx_p;
731 } else {
732 /** Arbitrary value */
733 enc->q_idx_idr = enc->q_idx_p = enc->q_idx_b = 128;
734 }
735
736 return 0;
737}
738
739static av_cold int init_sequence_headers(AVCodecContext *avctx)
740{

Callers 1

vulkan_encode_av1_initFunction · 0.70

Calls 2

av_logFunction · 0.85
fabsFunction · 0.85

Tested by

no test coverage detected