summaryrefslogtreecommitdiff
path: root/libavcodec/qsvenc.c
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2021-12-13 14:50:35 +0800
committerZhong Li <zhongli_dev@126.com>2021-12-19 22:14:51 +0800
commit50c38e1a4453f8073b980e91b336e7d94e65769a (patch)
tree74b9f1973f7c6f6359a097db819e7621a3665858 /libavcodec/qsvenc.c
parent3857ecbe70e81cb6ad7a7f155c311e8522b93b3e (diff)
lavc/qsvenc: define profile array per codec
The SDK defines HEVC, VP9 and AV1 profiles in the same values e.g. MFX_PROFILE_HEVC_MAIN =1, MFX_PROFILE_VP9_0 =1, MFX_PROFILE_AV1_MAIN =1, To avoid potential errors when adding VP9, AV1 profiles later, this patch defines profile array per codec. Signed-off-by: Zhong Li <zhongli_dev@126.com>
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r--libavcodec/qsvenc.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index dc0c45dc45..7dab8bab0f 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -41,10 +41,12 @@
#include "qsv_internal.h"
#include "qsvenc.h"
-static const struct {
+struct profile_names {
mfxU16 profile;
const char *name;
-} profile_names[] = {
+};
+
+static const struct profile_names avc_profiles[] = {
{ MFX_PROFILE_AVC_BASELINE, "baseline" },
{ MFX_PROFILE_AVC_MAIN, "main" },
{ MFX_PROFILE_AVC_EXTENDED, "extended" },
@@ -57,9 +59,15 @@ static const struct {
{ MFX_PROFILE_AVC_CONSTRAINED_HIGH, "constrained high" },
{ MFX_PROFILE_AVC_PROGRESSIVE_HIGH, "progressive high" },
#endif
+};
+
+static const struct profile_names mpeg2_profiles[] = {
{ MFX_PROFILE_MPEG2_SIMPLE, "simple" },
{ MFX_PROFILE_MPEG2_MAIN, "main" },
{ MFX_PROFILE_MPEG2_HIGH, "high" },
+};
+
+static const struct profile_names hevc_profiles[] = {
#if QSV_VERSION_ATLEAST(1, 8)
{ MFX_PROFILE_HEVC_MAIN, "main" },
{ MFX_PROFILE_HEVC_MAIN10, "main10" },
@@ -68,12 +76,35 @@ static const struct {
#endif
};
-static const char *print_profile(mfxU16 profile)
+static const char *print_profile(enum AVCodecID codec_id, mfxU16 profile)
{
- int i;
- for (i = 0; i < FF_ARRAY_ELEMS(profile_names); i++)
- if (profile == profile_names[i].profile)
- return profile_names[i].name;
+ const struct profile_names *profiles;
+ int i, num_profiles;
+
+ switch (codec_id) {
+ case AV_CODEC_ID_H264:
+ profiles = avc_profiles;
+ num_profiles = FF_ARRAY_ELEMS(avc_profiles);
+ break;
+
+ case AV_CODEC_ID_MPEG2VIDEO:
+ profiles = mpeg2_profiles;
+ num_profiles = FF_ARRAY_ELEMS(mpeg2_profiles);
+ break;
+
+ case AV_CODEC_ID_HEVC:
+ profiles = hevc_profiles;
+ num_profiles = FF_ARRAY_ELEMS(hevc_profiles);
+ break;
+
+ default:
+ return "unknown";
+ }
+
+ for (i = 0; i < num_profiles; i++)
+ if (profile == profiles[i].profile)
+ return profiles[i].name;
+
return "unknown";
}
@@ -143,7 +174,7 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q,
#endif
av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n",
- print_profile(info->CodecProfile), info->CodecLevel);
+ print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel);
av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag: ",
info->GopPicSize, info->GopRefDist);