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

Function vaapi_encode_h264_init

libavcodec/vaapi_encode_h264.c:991–1052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989};
990
991static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
992{
993 FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
994 VAAPIEncodeContext *ctx = avctx->priv_data;
995 VAAPIEncodeH264Context *priv = avctx->priv_data;
996
997 ctx->codec = &vaapi_encode_type_h264;
998
999 if (avctx->profile == AV_PROFILE_UNKNOWN)
1000 avctx->profile = priv->profile;
1001 if (avctx->level == AV_LEVEL_UNKNOWN)
1002 avctx->level = priv->level;
1003 if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
1004 avctx->compression_level = priv->quality;
1005
1006 // Reject unsupported profiles.
1007 switch (avctx->profile) {
1008 case AV_PROFILE_H264_BASELINE:
1009 av_log(avctx, AV_LOG_WARNING, "H.264 baseline profile is not "
1010 "supported, using constrained baseline profile instead.\n");
1011 avctx->profile = AV_PROFILE_H264_CONSTRAINED_BASELINE;
1012 break;
1013 case AV_PROFILE_H264_EXTENDED:
1014 av_log(avctx, AV_LOG_ERROR, "H.264 extended profile "
1015 "is not supported.\n");
1016 return AVERROR_PATCHWELCOME;
1017 case AV_PROFILE_H264_HIGH_10_INTRA:
1018 av_log(avctx, AV_LOG_ERROR, "H.264 high 10 intra profile "
1019 "is not supported.\n");
1020 return AVERROR_PATCHWELCOME;
1021 case AV_PROFILE_H264_HIGH_422:
1022 case AV_PROFILE_H264_HIGH_422_INTRA:
1023 case AV_PROFILE_H264_HIGH_444:
1024 case AV_PROFILE_H264_HIGH_444_PREDICTIVE:
1025 case AV_PROFILE_H264_HIGH_444_INTRA:
1026 case AV_PROFILE_H264_CAVLC_444:
1027 av_log(avctx, AV_LOG_ERROR, "H.264 non-4:2:0 profiles "
1028 "are not supported.\n");
1029 return AVERROR_PATCHWELCOME;
1030 }
1031
1032 if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0xff) {
1033 av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
1034 "in 8-bit unsigned integer.\n", avctx->level);
1035 return AVERROR(EINVAL);
1036 }
1037
1038 ctx->desired_packed_headers =
1039 VA_ENC_PACKED_HEADER_SEQUENCE | // SPS and PPS.
1040 VA_ENC_PACKED_HEADER_SLICE | // Slice headers.
1041 VA_ENC_PACKED_HEADER_MISC; // SEI.
1042
1043 base_ctx->surface_width = FFALIGN(avctx->width, 16);
1044 base_ctx->surface_height = FFALIGN(avctx->height, 16);
1045
1046 base_ctx->slice_block_height = base_ctx->slice_block_width = 16;
1047
1048 if (priv->qp > 0)

Callers

nothing calls this directly

Calls 2

av_logFunction · 0.85
ff_vaapi_encode_initFunction · 0.85

Tested by

no test coverage detected