1 /*! 2 * \copy 3 * Copyright (c) 2009-2013, Cisco Systems 4 * 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 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * 32 * \brief Tool kits for decoder 33 * ( malloc, realloc, free, log output and PSNR calculation and so on ) 34 * 35 * \date 03/10/2009 Created 36 * 37 ************************************************************************************* 38 */ 39 #ifndef WELS_UTILS_H__ 40 #define WELS_UTILS_H__ 41 42 #include <stdarg.h> 43 #include "typedefs.h" 44 45 #define MAX_LOG_SIZE 1024 46 #define MAX_MBS_PER_FRAME 36864 //in accordance with max level support in Rec 47 /* 48 * Function pointer declaration for various tool sets 49 */ 50 // wels log output 51 typedef void (*PWelsLogCallbackFunc) (void* pCtx, const int32_t iLevel, const char* kpFmt, va_list argv); 52 53 typedef struct TagLogContext { 54 PWelsLogCallbackFunc pfLog; 55 void* pLogCtx; 56 void* pCodecInstance; 57 } SLogContext; 58 59 60 #ifdef __GNUC__ 61 extern void WelsLog (SLogContext* pCtx, int32_t iLevel, const char* kpFmt, ...) __attribute__ ((__format__ (__printf__, 62 3, 63 4))); 64 #else 65 extern void WelsLog (SLogContext* pCtx, int32_t iLevel, const char* kpFmt, ...); 66 #endif 67 68 /* 69 * PSNR calculation routines 70 */ 71 /*! 72 ************************************************************************************* 73 * \brief PSNR calculation utilization in Wels 74 * 75 * \param kpTarPic target picture to be calculated in Picture pData format 76 * \param kiTarStride stride of target picture pData pBuffer 77 * \param kpRefPic base referencing picture samples 78 * \param kiRefStride stride of reference picture pData pBuffer 79 * \param kiWidth picture iWidth in pixel 80 * \param kiHeight picture iHeight in pixel 81 * 82 * \return actual PSNR result; 83 * 84 * \note N/A 85 ************************************************************************************* 86 */ 87 float WelsCalcPsnr (const void* kpTarPic, 88 const int32_t kiTarStride, 89 const void* kpRefPic, 90 const int32_t kiRefStride, 91 const int32_t kiWidth, 92 const int32_t kiHeight); 93 94 95 #endif//WELS_UTILS_H__ 96