xref: /OK3568_Linux_fs/external/mpp/mpp/base/mpp_2str.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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     };
57 
58     if (coding >= MPP_VIDEO_CodingUnused && coding <= MPP_VIDEO_CodingVP9)
59         return coding_type_str0[coding];
60     else if (coding >= MPP_VIDEO_CodingVC1 && coding <= MPP_VIDEO_CodingAVS)
61         return coding_type_str1[coding - MPP_VIDEO_CodingVC1];
62 
63     return NULL;
64 }
65 
strof_rc_mode(MppEncRcMode rc_mode)66 const char *strof_rc_mode(MppEncRcMode rc_mode)
67 {
68     static const char *rc_mode_str[] = {
69         "vbr",
70         "cbr",
71         "fixqp",
72         "avbr",
73     };
74 
75     if (rc_mode >= MPP_ENC_RC_MODE_VBR && rc_mode < MPP_ENC_RC_MODE_BUTT)
76         return rc_mode_str[rc_mode];
77 
78     return NULL;
79 }
strof_gop_mode(MppEncRcGopMode gop_mode)80 const char *strof_gop_mode(MppEncRcGopMode gop_mode)
81 {
82     static const char *gop_mode_str[] = {
83         "normalp",
84         "smartp",
85     };
86 
87     if (gop_mode >= MPP_ENC_RC_NORMAL_P && gop_mode < MPP_ENC_RC_GOP_MODE_BUTT)
88         return gop_mode_str[gop_mode];
89 
90     return NULL;
91 }
92 
strof_profle(MppCodingType coding,RK_U32 profile)93 const char *strof_profle(MppCodingType coding, RK_U32 profile)
94 {
95     static const char *h264_profile_str[] = {
96         "baseline",
97         "main",
98         "high",
99         "high10",
100     };
101     static const char *h265_profile_str[] = {
102         "main",
103         "main10",
104     };
105     static const char *jpeg_profile_str[] = {
106         "base",
107     };
108     static const char *vp8_profile_str[] = {
109         "base",
110     };
111     static const char *unknown_str[] = {
112         "unknown",
113     };
114 
115     switch (coding) {
116     case MPP_VIDEO_CodingAVC : {
117         if (profile == H264_PROFILE_BASELINE)
118             return h264_profile_str[0];
119         else if (profile == H264_PROFILE_MAIN)
120             return h264_profile_str[1];
121         else if (profile == H264_PROFILE_HIGH)
122             return h264_profile_str[2];
123         else if (profile == H264_PROFILE_HIGH10)
124             return h264_profile_str[3];
125         else
126             return unknown_str[0];
127     } break;
128     case MPP_VIDEO_CodingHEVC : {
129         if (profile < 2)
130             return h265_profile_str[0];
131         else
132             return unknown_str[0];
133     } break;
134     case MPP_VIDEO_CodingMJPEG : {
135         return jpeg_profile_str[0];
136     } break;
137     case MPP_VIDEO_CodingVP8 : {
138         return vp8_profile_str[0];
139     } break;
140     default : {
141     } break;
142     }
143 
144     return NULL;
145 }
146