Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2018-09-19 01:30:40 +0300
committerMark Thompson <sw@jkqxz.net>2018-09-23 16:42:33 +0300
commit3b188666f19a17d15efb7eae590e988832972666 (patch)
tree9442d49ab736e26b84bf4983cf3e781cdc076a32 /libavcodec/vaapi_encode_mpeg2.c
parenta00763be8861bcf499675b2af89d29e4e113cdc9 (diff)
vaapi_encode: Choose profiles dynamically
Previously there was one fixed choice for each codec (e.g. H.265 -> Main profile), and using anything else then required an explicit option from the user. This changes to selecting the profile based on the input format and the set of profiles actually supported by the driver (e.g. P010 input will choose Main 10 profile for H.265 if the driver supports it). The entrypoint and render target format are also chosen dynamically in the same way, removing those explicit selections from the per-codec code.
Diffstat (limited to 'libavcodec/vaapi_encode_mpeg2.c')
-rw-r--r--libavcodec/vaapi_encode_mpeg2.c36
1 files changed, 8 insertions, 28 deletions
diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c
index 5577fa9e04..7f6c7833da 100644
--- a/libavcodec/vaapi_encode_mpeg2.c
+++ b/libavcodec/vaapi_encode_mpeg2.c
@@ -552,7 +552,15 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx)
return 0;
}
+static const VAAPIEncodeProfile vaapi_encode_mpeg2_profiles[] = {
+ { FF_PROFILE_MPEG2_MAIN, 8, 3, 1, 1, VAProfileMPEG2Main },
+ { FF_PROFILE_MPEG2_SIMPLE, 8, 3, 1, 1, VAProfileMPEG2Simple },
+ { FF_PROFILE_UNKNOWN }
+};
+
static const VAAPIEncodeType vaapi_encode_type_mpeg2 = {
+ .profiles = vaapi_encode_mpeg2_profiles,
+
.configure = &vaapi_encode_mpeg2_configure,
.sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2),
@@ -577,31 +585,6 @@ static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx)
ctx->codec = &vaapi_encode_type_mpeg2;
- switch (avctx->profile) {
- case FF_PROFILE_MPEG2_SIMPLE:
- ctx->va_profile = VAProfileMPEG2Simple;
- break;
- case FF_PROFILE_MPEG2_MAIN:
- ctx->va_profile = VAProfileMPEG2Main;
- break;
- case FF_PROFILE_MPEG2_422:
- av_log(avctx, AV_LOG_ERROR, "MPEG-2 4:2:2 profile "
- "is not supported.\n");
- return AVERROR_PATCHWELCOME;
- case FF_PROFILE_MPEG2_HIGH:
- av_log(avctx, AV_LOG_ERROR, "MPEG-2 high profile "
- "is not supported.\n");
- return AVERROR_PATCHWELCOME;
- case FF_PROFILE_MPEG2_SS:
- case FF_PROFILE_MPEG2_SNR_SCALABLE:
- av_log(avctx, AV_LOG_ERROR, "MPEG-2 scalable profiles "
- "are not supported.\n");
- return AVERROR_PATCHWELCOME;
- default:
- av_log(avctx, AV_LOG_ERROR, "Unknown MPEG-2 profile %d.\n",
- avctx->profile);
- return AVERROR(EINVAL);
- }
switch (avctx->level) {
case 4: // High
case 6: // High 1440
@@ -620,8 +603,6 @@ static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- ctx->va_entrypoint = VAEntrypointEncSlice;
- ctx->va_rt_format = VA_RT_FORMAT_YUV420;
ctx->va_rc_mode = VA_RC_CQP;
ctx->va_packed_headers = VA_ENC_PACKED_HEADER_SEQUENCE |
@@ -643,7 +624,6 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx)
}
static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = {
- { "profile", "4" },
{ "level", "4" },
{ "bf", "1" },
{ "g", "120" },