xref: /rockchip-linux_mpp/mpp/base/mpp_2str.c (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  *
3  * Copyright 2015 Rockchip Electronics Co. LTD
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include "mpp_2str.h"
19 #include "h264_syntax.h"
20 #include "h265_syntax.h"
21 
strof_ctx_type(MppCtxType type)22 const char *strof_ctx_type(MppCtxType type)
23 {
24     static const char *ctx_type_str[MPP_CTX_BUTT] = {
25         "dec",
26         "enc",
27         "isp",
28     };
29 
30     return ctx_type_str[type];
31 }
32 
strof_coding_type(MppCodingType coding)33 const char *strof_coding_type(MppCodingType coding)
34 {
35     static const char *coding_type_str0[] = {
36         "unused",
37         "autodetect",
38         "mpeg2",
39         "h263",
40         "mpeg4",
41         "wmv",
42         "rv",
43         "h264",
44         "mjpeg",
45         "vp8",
46         "vp9",
47     };
48     static const char *coding_type_str1[] = {
49         "vc1",
50         "flv1",
51         "divx3",
52         "vp6",
53         "h265",
54         "avs+",
55         "avs",
56         "avs2",
57         "av1",
58     };
59 
60     if (coding >= MPP_VIDEO_CodingUnused && coding <= MPP_VIDEO_CodingVP9)
61         return coding_type_str0[coding];
62     else if (coding >= MPP_VIDEO_CodingVC1 && coding <= MPP_VIDEO_CodingAV1)
63         return coding_type_str1[coding - MPP_VIDEO_CodingVC1];
64 
65     return NULL;
66 }
67 
strof_rc_mode(MppEncRcMode rc_mode)68 const char *strof_rc_mode(MppEncRcMode rc_mode)
69 {
70     static const char *rc_mode_str[] = {
71         "vbr",
72         "cbr",
73         "fixqp",
74         "avbr",
75         "smtrc"
76     };
77 
78     if (rc_mode >= MPP_ENC_RC_MODE_VBR && rc_mode < MPP_ENC_RC_MODE_BUTT)
79         return rc_mode_str[rc_mode];
80 
81     return NULL;
82 }
strof_gop_mode(MppEncRcGopMode gop_mode)83 const char *strof_gop_mode(MppEncRcGopMode gop_mode)
84 {
85     static const char *gop_mode_str[] = {
86         "normalp",
87         "smartp",
88     };
89 
90     if (gop_mode >= MPP_ENC_RC_NORMAL_P && gop_mode < MPP_ENC_RC_GOP_MODE_BUTT)
91         return gop_mode_str[gop_mode];
92 
93     return NULL;
94 }
95 
strof_profle(MppCodingType coding,RK_U32 profile)96 const char *strof_profle(MppCodingType coding, RK_U32 profile)
97 {
98     static const char *h264_profile_str[] = {
99         "baseline",
100         "main",
101         "high",
102         "high10",
103     };
104     static const char *h265_profile_str[] = {
105         "main",
106         "main10",
107     };
108     static const char *jpeg_profile_str[] = {
109         "base",
110     };
111     static const char *vp8_profile_str[] = {
112         "base",
113     };
114     static const char *unknown_str[] = {
115         "unknown",
116     };
117 
118     switch (coding) {
119     case MPP_VIDEO_CodingAVC : {
120         if (profile == H264_PROFILE_BASELINE)
121             return h264_profile_str[0];
122         else if (profile == H264_PROFILE_MAIN)
123             return h264_profile_str[1];
124         else if (profile == H264_PROFILE_HIGH)
125             return h264_profile_str[2];
126         else if (profile == H264_PROFILE_HIGH10)
127             return h264_profile_str[3];
128         else
129             return unknown_str[0];
130     } break;
131     case MPP_VIDEO_CodingHEVC : {
132         if (profile < 2)
133             return h265_profile_str[0];
134         else
135             return unknown_str[0];
136     } break;
137     case MPP_VIDEO_CodingMJPEG : {
138         return jpeg_profile_str[0];
139     } break;
140     case MPP_VIDEO_CodingVP8 : {
141         return vp8_profile_str[0];
142     } break;
143     default : {
144     } break;
145     }
146 
147     return NULL;
148 }
149