1 /*! 2 * \copy 3 * Copyright (c) 2011-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 * \file : denoise.h 32 * 33 * \brief : denoise class of wels video processor class 34 * 35 * \date : 2011/03/15 36 * 37 * \description : 1. rewrite the package code of denoise class 38 * 39 ************************************************************************************* 40 */ 41 42 #ifndef WELSVP_DENOISE_H 43 #define WELSVP_DENOISE_H 44 45 #include "util.h" 46 #include "memory.h" 47 #include "WelsFrameWork.h" 48 #include "IWelsVP.h" 49 50 51 #define DENOISE_GRAY_RADIUS (1) 52 #define DENOISE_GRAY_SIGMA (2) 53 54 #define UV_WINDOWS_RADIUS (2) 55 #define TAIL_OF_LINE8 (7) 56 57 #define DENOISE_Y_COMPONENT (1) 58 #define DENOISE_U_COMPONENT (2) 59 #define DENOISE_V_COMPONENT (4) 60 #define DENOISE_ALL_COMPONENT (7) 61 62 63 WELSVP_NAMESPACE_BEGIN 64 65 void Gauss3x3Filter (uint8_t* pixels, int32_t stride); 66 67 typedef void (DenoiseFilterFunc) (uint8_t* pixels, int32_t stride); 68 69 typedef DenoiseFilterFunc* DenoiseFilterFuncPtr; 70 71 DenoiseFilterFunc BilateralLumaFilter8_c; 72 DenoiseFilterFunc WaverageChromaFilter8_c; 73 74 #ifdef X86_ASM 75 WELSVP_EXTERN_C_BEGIN 76 DenoiseFilterFunc BilateralLumaFilter8_sse2 ; 77 DenoiseFilterFunc WaverageChromaFilter8_sse2 ; 78 WELSVP_EXTERN_C_END 79 #endif 80 81 typedef struct TagDenoiseFuncs { 82 DenoiseFilterFuncPtr pfBilateralLumaFilter8;//on 8 samples 83 DenoiseFilterFuncPtr pfWaverageChromaFilter8;//on 8 samples 84 } SDenoiseFuncs; 85 86 class CDenoiser : public IStrategy { 87 public: 88 CDenoiser (int32_t iCpuFlag); 89 ~CDenoiser(); 90 91 EResult Process (int32_t iType, SPixMap* pSrc, SPixMap* dst); 92 93 private: 94 void InitDenoiseFunc (SDenoiseFuncs& pf, int32_t cpu); 95 void BilateralDenoiseLuma (uint8_t* p_y_data, int32_t width, int32_t height, int32_t stride); 96 void WaverageDenoiseChroma (uint8_t* pSrcUV, int32_t width, int32_t height, int32_t stride); 97 98 private: 99 float m_fSigmaGrey; //sigma for grey scale similarity, suggestion 2.5-3 100 uint16_t m_uiSpaceRadius; //filter windows radius: 1-3x3, 2-5x5,3-7x7. Larger size, slower speed 101 uint16_t m_uiType; //do denoising on which component 1-Y, 2-U, 4-V; 7-YUV, 3-YU, 5-YV, 6-UV 102 103 SDenoiseFuncs m_pfDenoise; 104 int32_t m_CPUFlag; 105 }; 106 107 WELSVP_NAMESPACE_END 108 109 #endif 110