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

Function ff_mpv_encode_init

libavcodec/mpegvideo_enc.c:553–1086  ·  view source on GitHub ↗

init video encoder */

Source from the content-addressed store, hash-verified

551
552/* init video encoder */
553av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
554{
555 MPVMainEncContext *const m = avctx->priv_data;
556 MPVEncContext *const s = &m->s;
557 AVCPBProperties *cpb_props;
558 int gcd, ret;
559
560 mpv_encode_defaults(m);
561
562 switch (avctx->pix_fmt) {
563 case AV_PIX_FMT_YUVJ444P:
564 case AV_PIX_FMT_YUV444P:
565 s->c.chroma_format = CHROMA_444;
566 break;
567 case AV_PIX_FMT_YUVJ422P:
568 case AV_PIX_FMT_YUV422P:
569 s->c.chroma_format = CHROMA_422;
570 break;
571 default:
572 av_unreachable("Already checked via CODEC_PIXFMTS");
573 case AV_PIX_FMT_YUVJ420P:
574 case AV_PIX_FMT_YUV420P:
575 s->c.chroma_format = CHROMA_420;
576 break;
577 }
578
579 avctx->bits_per_raw_sample = av_clip(avctx->bits_per_raw_sample, 0, 8);
580
581 m->bit_rate = avctx->bit_rate;
582 s->c.width = avctx->width;
583 s->c.height = avctx->height;
584 if (avctx->gop_size > 600 &&
585 avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
586 av_log(avctx, AV_LOG_WARNING,
587 "keyframe interval too large!, reducing it from %d to %d\n",
588 avctx->gop_size, 600);
589 avctx->gop_size = 600;
590 }
591 m->gop_size = avctx->gop_size;
592 s->c.avctx = avctx;
593 if (avctx->max_b_frames > MPVENC_MAX_B_FRAMES) {
594 av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum "
595 "is " AV_STRINGIFY(MPVENC_MAX_B_FRAMES) ".\n");
596 avctx->max_b_frames = MPVENC_MAX_B_FRAMES;
597 } else if (avctx->max_b_frames < 0) {
598 av_log(avctx, AV_LOG_ERROR,
599 "max b frames must be 0 or positive for mpegvideo based encoders\n");
600 return AVERROR(EINVAL);
601 }
602 m->max_b_frames = avctx->max_b_frames;
603 s->c.codec_id = avctx->codec->id;
604 if (m->max_b_frames && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
605 av_log(avctx, AV_LOG_ERROR, "B-frames not supported by codec\n");
606 return AVERROR(EINVAL);
607 }
608
609 s->c.quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0;
610 s->rtp_mode = !!s->rtp_payload_size;

Callers 7

wmv2_encode_initFunction · 0.85
rv10_encode_initFunction · 0.85
h261_encode_initFunction · 0.85
encode_initFunction · 0.85
mjpeg_encode_initFunction · 0.85
speedhq_encode_initFunction · 0.85
encode_initFunction · 0.85

Calls 15

mpv_encode_defaultsFunction · 0.85
av_logFunction · 0.85
av_q2dFunction · 0.85
av_reduceFunction · 0.85
av_gcdFunction · 0.85
ff_match_2uint16Function · 0.85
ff_mpv_idct_initFunction · 0.85
init_unquantizeFunction · 0.85
ff_fdctdsp_initFunction · 0.85
ff_mpegvideoencdsp_initFunction · 0.85
ff_pixblockdsp_initFunction · 0.85
me_cmp_initFunction · 0.85

Tested by

no test coverage detected