1 /** 2 * @copyright 3 * 4 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * * Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * * Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * * Neither the name of The Linux Foundation nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 28 * DAMAGE. 29 * 30 * @file 31 * 32 * omx_swvdec_utils.h 33 * 34 * @brief 35 * 36 * OMX software video decoder utility functions header. 37 */ 38 39 #ifndef _OMX_SWVDEC_UTILS_H_ 40 #define _OMX_SWVDEC_UTILS_H_ 41 42 #include <queue> 43 #include <pthread.h> 44 45 #include <utils/Log.h> 46 47 extern unsigned int g_omx_swvdec_logmask; 48 ///< global OMX SwVdec logmask variable extern declaration 49 50 void omx_swvdec_log_init(); 51 52 #define OMX_SWVDEC_LOGMASK_LOW 4 ///< 100: logmask for low priority logs 53 #define OMX_SWVDEC_LOGMASK_HIGH 2 ///< 010: logmask for high priority logs 54 #define OMX_SWVDEC_LOGMASK_ERROR 1 ///< 001: logmask for error priority logs 55 56 #ifdef LOG_TAG 57 #undef LOG_TAG 58 #endif 59 #define LOG_TAG "OMX_SWVDEC" ///< OMX SwVdec log tag 60 61 /// low priority log message 62 #define OMX_SWVDEC_LOG_LOW(string, ...) \ 63 do { \ 64 if (g_omx_swvdec_logmask & OMX_SWVDEC_LOGMASK_LOW) \ 65 ALOGD("--- %s(): " string, __FUNCTION__, ##__VA_ARGS__); \ 66 } while (0) 67 68 /// high priority log message 69 #define OMX_SWVDEC_LOG_HIGH(string, ...) \ 70 do { \ 71 if (g_omx_swvdec_logmask & OMX_SWVDEC_LOGMASK_HIGH) \ 72 ALOGI("--- %s(): " string, __FUNCTION__, ##__VA_ARGS__); \ 73 } while (0) 74 75 /// error priority log message 76 #define OMX_SWVDEC_LOG_ERROR(string, ...) \ 77 do { \ 78 if (g_omx_swvdec_logmask & OMX_SWVDEC_LOGMASK_ERROR) \ 79 ALOGE("!!! %s(): " string, __FUNCTION__, ##__VA_ARGS__); \ 80 } while (0) 81 82 /// high priority log message for OMX SwVdec API calls 83 #define OMX_SWVDEC_LOG_API(string, ...) \ 84 do { \ 85 if (g_omx_swvdec_logmask & OMX_SWVDEC_LOGMASK_HIGH) \ 86 ALOGI(">>> %s(): " string, __FUNCTION__, ##__VA_ARGS__); \ 87 } while (0) 88 89 /// high priority log message for OMX SwVdec callbacks 90 #define OMX_SWVDEC_LOG_CALLBACK(string, ...) \ 91 do { \ 92 if (g_omx_swvdec_logmask & OMX_SWVDEC_LOGMASK_HIGH) \ 93 ALOGI("<<< %s(): " string, __FUNCTION__, ##__VA_ARGS__); \ 94 } while (0) 95 96 /// OMX SwVdec event information structure 97 typedef struct { 98 unsigned long event_id; ///< event ID 99 unsigned long event_param1; ///< event parameter 1 100 unsigned long event_param2; ///< event parameter 2 101 } OMX_SWVDEC_EVENT_INFO; 102 103 /// OMX SwVdec queue class 104 class omx_swvdec_queue 105 { 106 public: 107 omx_swvdec_queue(); 108 ~omx_swvdec_queue(); 109 110 void push(OMX_SWVDEC_EVENT_INFO *p_event_info); 111 bool pop(OMX_SWVDEC_EVENT_INFO *p_event_info); 112 113 private: 114 std::queue<OMX_SWVDEC_EVENT_INFO> m_queue; ///< queue 115 pthread_mutex_t m_mutex; ///< mutex 116 }; 117 118 #define DIAG_FILE_PATH "/data/vendor/media" ///< file path 119 120 /// OMX SwVdec diagnostics class 121 class omx_swvdec_diag 122 { 123 public: 124 omx_swvdec_diag(); 125 ~omx_swvdec_diag(); 126 127 void dump_ip(unsigned char *p_buffer, unsigned int filled_length); 128 void dump_op(unsigned char *p_buffer, 129 unsigned int width, 130 unsigned int height, 131 unsigned int stride, 132 unsigned int scanlines); 133 134 private: 135 unsigned int m_dump_ip; ///< dump input bitstream 136 unsigned int m_dump_op; ///< dump output YUV 137 138 char *m_filename_ip; ///< input filename string 139 char *m_filename_op; ///< output filename string 140 141 FILE *m_file_ip; ///< input file handle 142 FILE *m_file_op; ///< output file handle 143 }; 144 145 #endif // #ifndef _OMX_SWVDEC_UTILS_H_ 146