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

Function encode_preinit_video

libavcodec/encode.c:545–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543}
544
545static int encode_preinit_video(AVCodecContext *avctx)
546{
547 const AVCodec *c = avctx->codec;
548 const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
549 const enum AVPixelFormat *pix_fmts;
550 int ret, i, num_pix_fmts;
551
552 if (!pixdesc) {
553 av_log(avctx, AV_LOG_ERROR, "Invalid video pixel format: %d\n",
554 avctx->pix_fmt);
555 return AVERROR(EINVAL);
556 }
557
558 ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT,
559 0, (const void **) &pix_fmts, &num_pix_fmts);
560 if (ret < 0)
561 return ret;
562
563 if (pix_fmts) {
564 for (i = 0; i < num_pix_fmts; i++)
565 if (avctx->pix_fmt == pix_fmts[i])
566 break;
567 if (i == num_pix_fmts) {
568 av_log(avctx, AV_LOG_ERROR,
569 "Specified pixel format %s is not supported by the %s encoder.\n",
570 av_get_pix_fmt_name(avctx->pix_fmt), c->name);
571
572 av_log(avctx, AV_LOG_ERROR, "Supported pixel formats:\n");
573 for (int p = 0; pix_fmts[p] != AV_PIX_FMT_NONE; p++) {
574 av_log(avctx, AV_LOG_ERROR, " %s\n",
575 av_get_pix_fmt_name(pix_fmts[p]));
576 }
577
578 return AVERROR(EINVAL);
579 }
580 if (pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
581 pix_fmts[i] == AV_PIX_FMT_YUVJ411P ||
582 pix_fmts[i] == AV_PIX_FMT_YUVJ422P ||
583 pix_fmts[i] == AV_PIX_FMT_YUVJ440P ||
584 pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
585 avctx->color_range = AVCOL_RANGE_JPEG;
586 }
587
588 if (pixdesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
589 const enum AVAlphaMode *alpha_modes;
590 int num_alpha_modes;
591 ret = avcodec_get_supported_config(avctx, NULL, AV_CODEC_CONFIG_ALPHA_MODE,
592 0, (const void **) &alpha_modes, &num_alpha_modes);
593 if (ret < 0)
594 return ret;
595
596 if (avctx->alpha_mode != AVALPHA_MODE_UNSPECIFIED && alpha_modes) {
597 for (i = 0; i < num_alpha_modes; i++) {
598 if (avctx->alpha_mode == alpha_modes[i])
599 break;
600 }
601 if (i == num_alpha_modes) {
602 av_log(avctx, AV_LOG_ERROR,

Callers 1

ff_encode_preinitFunction · 0.85

Calls 5

av_pix_fmt_desc_getFunction · 0.85
av_logFunction · 0.85
av_get_pix_fmt_nameFunction · 0.85
av_alpha_mode_nameFunction · 0.85

Tested by

no test coverage detected