From b60b40c62d19b77ece68d190736e1d5acbe70880 Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Fri, 6 Nov 2020 14:06:06 +0800 Subject: [PATCH] [mpp_base]: Add more to_str function Change-Id: Ic45acd7cb304fa16908e43ec497d9ead8ba477d6 Signed-off-by: Herman Chen --- mpp/base/inc/mpp_2str.h | 3 ++ mpp/base/mpp_2str.c | 71 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/mpp/base/inc/mpp_2str.h b/mpp/base/inc/mpp_2str.h index ac0bee75..9ac04268 100644 --- a/mpp/base/inc/mpp_2str.h +++ b/mpp/base/inc/mpp_2str.h @@ -19,6 +19,7 @@ #define __MPP_2STR_H__ #include "rk_type.h" +#include "rk_venc_rc.h" #ifdef __cplusplus extern "C" { @@ -26,6 +27,8 @@ extern "C" { const char *strof_ctx_type(MppCtxType type); const char *strof_coding_type(MppCodingType coding); +const char *strof_rc_mode(MppEncRcMode rc_mode); +const char *strof_profle(MppCodingType coding, RK_U32 profile); #ifdef __cplusplus } diff --git a/mpp/base/mpp_2str.c b/mpp/base/mpp_2str.c index 9ef06f2b..2c365780 100644 --- a/mpp/base/mpp_2str.c +++ b/mpp/base/mpp_2str.c @@ -16,6 +16,8 @@ */ #include "mpp_2str.h" +#include "h264_syntax.h" +#include "h265_syntax.h" const char *strof_ctx_type(MppCtxType type) { @@ -60,3 +62,72 @@ const char *strof_coding_type(MppCodingType coding) return NULL; } + +const char *strof_rc_mode(MppEncRcMode rc_mode) +{ + static const char *rc_mode_str[] = { + "vbr", + "cbr", + "fixqp", + "avbr", + }; + + if (rc_mode >= MPP_ENC_RC_MODE_VBR && rc_mode < MPP_ENC_RC_MODE_BUTT) + return rc_mode_str[rc_mode]; + + return NULL; +} + +const char *strof_profle(MppCodingType coding, RK_U32 profile) +{ + static const char *h264_profile_str[] = { + "baseline", + "main", + "high", + "high10", + }; + static const char *h265_profile_str[] = { + "main", + "main10", + }; + static const char *jpeg_profile_str[] = { + "base", + }; + static const char *vp8_profile_str[] = { + "base", + }; + static const char *unknown_str[] = { + "unknown", + }; + + switch (coding) { + case MPP_VIDEO_CodingAVC : { + if (profile == H264_PROFILE_BASELINE) + return h264_profile_str[0]; + else if (profile == H264_PROFILE_MAIN) + return h264_profile_str[1]; + else if (profile == H264_PROFILE_HIGH) + return h264_profile_str[2]; + else if (profile == H264_PROFILE_HIGH10) + return h264_profile_str[3]; + else + return unknown_str[0]; + } break; + case MPP_VIDEO_CodingHEVC : { + if (profile < 2) + return h265_profile_str[0]; + else + return unknown_str[0]; + } break; + case MPP_VIDEO_CodingMJPEG : { + return jpeg_profile_str[0]; + } break; + case MPP_VIDEO_CodingVP8 : { + return vp8_profile_str[0]; + } break; + default : { + } break; + } + + return NULL; +}