xref: /rockchip-linux_mpp/mpp/codec/dec/m2v/m2vd_com.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __M2VD_COM_H__
18 #define __M2VD_COM_H__
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 
23 #include "mpp_debug.h"
24 
25 #define M2VD_DEMO_MODE         0
26 
27 //------------------------ temp ---------------------------------
28 #define M2VD_TEST_TRACE       (0x00000001)
29 #define M2VD_TEST_TIME        (0x00000002)
30 #define M2VD_TEST_MUTI_THREAD (0x00000004)
31 #define M2VD_TEST_DUMPYUV     (0x00000008)
32 #define M2VD_TEST_FPGA        (0x00000010)
33 
34 //log of diff
35 #define M2VD_DBG_FUNCTION          (0x00000001)
36 #define M2VD_DBG_ASSERT            (0x00000002)
37 #define M2VD_DBG_WARNNING          (0x00000004)
38 #define M2VD_DBG_LOG               (0x00000008)
39 #define M2VD_DBG_SEC_HEADER        (0x00000010)
40 #define M2VD_DBG_DUMP_REG          (0x00000020)
41 
42 
43 
44 
45 extern RK_U32 m2vd_debug;
46 
47 #define M2VD_ERR(fmt, ...)\
48 do {\
49         { mpp_log(fmt, ## __VA_ARGS__); }\
50 } while (0)
51 
52 #define M2VD_ASSERT(val)\
53 do {\
54     if (M2VD_DBG_ASSERT & m2vd_debug)\
55         { mpp_assert(val); }\
56 } while (0)
57 
58 #define M2VD_WARNNING(fmt, ...)\
59 do {\
60     if (M2VD_DBG_WARNNING & m2vd_debug)\
61         { mpp_log(fmt, ## __VA_ARGS__); }\
62 } while (0)
63 
64 #define M2VD_LOG(fmt, ...)\
65 do {\
66     if (M2VD_DBG_LOG & m2vd_debug)\
67         {  mpp_log(fmt, ## __VA_ARGS__); }\
68 } while (0)
69 
70 
71 //check function return
72 #define M2VD_CHK_F(val)                                            \
73     do{                                                       \
74         if((val) < 0) {                                       \
75             ret = (val);                                      \
76             M2VD_WARNNING("func return error(L%d), ret:%d\n", __LINE__, ret); \
77             goto __FAILED;                                    \
78         }                                                     \
79       } while (0)
80 
81 //check value if is zero or NULL
82 #define M2VD_CHK_V(val, ...)\
83     do{ if(!(val)){\
84     ret = MPP_ERR_VALUE;\
85     M2VD_WARNNING("value error(L%d), val:%d\n", __LINE__, val);\
86     goto __FAILED;\
87     } } while (0)
88 
89 //memory malloc check
90 #define M2VD_CHK_M(val, ...)\
91     do{ if(!(val)) {\
92     ret = MPP_ERR_MALLOC;\
93     M2VD_ERR("malloc buffer error(%d), pointer:%p\n", __LINE__, val);\
94     M2VD_ASSERT(0); goto __FAILED;\
95     } } while (0)
96 
97 //file check
98 #define M2VD_CHK_FILE(val, path, ...)\
99     do{ if(!(val)) {\
100             ret = MPP_ERR_OPEN_FILE;\
101             M2VD_WARNNING("open file error(line%d): %s\n", __LINE__, path);\
102             M2VD_ASSERT(0); goto __FAILED;\
103     } } while (0)
104 
105 //!< input check
106 #define M2VD_CHK_I(val, ...)\
107     do{ if(!(val)) {\
108     ret = MPP_ERR_INIT;\
109     M2VD_WARNNING("input empty(%d), val:%d\n", __LINE__, val);\
110     goto __FAILED;\
111     } } while (0)
112 
113 #define m2vd_dbg_func(tag) \
114     do {\
115         if (M2VD_DBG_FUNCTION & m2vd_debug)\
116             { mpp_log("%s: line(%d), func(%s)", tag, __LINE__, __FUNCTION__); }\
117     } while (0)
118 
119 
120 
121 
122 #define  M2VD_FCLOSE(fp)    do{ if(fp) fclose(fp); fp = NULL; } while (0)
123 
124 #endif
125