History

resolve conflict

volvet committed 12 years ago

Commit ec84f4b1 parent 3958118124 files · +15352 −15696Browse files

Showing the changes to codec/processing/src/denoise/denoise_filter.cpp (1 of 124 files). Show all

Unified · Split

codec/processing/src/denoise/denoise_filter.cpp+127−0
@@ -0,0 +1,127 @@
1+/*!
2+ * \copy
3+ * Copyright (c) 2010-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 svc_preprocess.h
32+ *
33+ * \brief svc denoising
34+ *
35+ * \date 4/1/2010 Created
36+ *
37+ */
38+
39+#include "denoise.h"
40+#include "../common/typedef.h"
41+
42+WELSVP_NAMESPACE_BEGIN
43+
44+void BilateralLumaFilter8_c (uint8_t* pSample, int32_t iStride) {
45+ int32_t nSum = 0, nTotWeight = 0;
46+ int32_t iCenterSample = *pSample;
47+ uint8_t* pCurLine = pSample - iStride - DENOISE_GRAY_RADIUS;
48+ int32_t x, y;
49+ int32_t iCurSample, iCurWeight, iGreyDiff;
50+ uint8_t aSample[8];
51+
52+ for (int32_t i = 0; i < 8; i++) {
53+ nSum = 0;
54+ nTotWeight = 0;
55+ iCenterSample = *pSample;
56+ pCurLine = pSample - iStride - DENOISE_GRAY_RADIUS;
57+ for (y = 0; y < 3; y++) {
58+ for (x = 0; x < 3; x++) {
59+ if (x == 1 && y == 1) continue; // except center point
60+ iCurSample = pCurLine[x];
61+ iCurWeight = WELS_ABS (iCurSample - iCenterSample);
62+ iGreyDiff = 32 - iCurWeight;
63+ if (iGreyDiff < 0) continue;
64+ else iCurWeight = (iGreyDiff * iGreyDiff) >> 5;
65+ nSum += iCurSample * iCurWeight;
66+ nTotWeight += iCurWeight;
67+ }
68+ pCurLine += iStride;
69+ }
70+ nTotWeight = 256 - nTotWeight;
71+ nSum += iCenterSample * nTotWeight;
72+ aSample[i] = nSum >> 8;
73+ pSample++;
74+ }
75+ WelsMemcpy (pSample - 8, aSample, 8);
76+}
77+
78+
79+/***************************************************************************
80+5x5 filter:
81+1 1 2 1 1
82+1 2 4 2 1
83+2 4 20 4 2
84+1 2 4 2 1
85+1 1 2 1 1
86+***************************************************************************/
87+#define SUM_LINE1(pSample) (pSample[0] +(pSample[1]) +(pSample[2]<<1) + pSample[3] + pSample[4])
88+#define SUM_LINE2(pSample) (pSample[0] +(pSample[1]<<1) +(pSample[2]<<2) +(pSample[3]<<1) +pSample[4])
89+#define SUM_LINE3(pSample) ((pSample[0]<<1) +(pSample[1]<<2) +(pSample[2]*20) +(pSample[3]<<2) +(pSample[4]<<1))
90+void WaverageChromaFilter8_c (uint8_t* pSample, int32_t iStride) {
91+ int32_t sum;
92+ uint8_t* pStartPixels = pSample - UV_WINDOWS_RADIUS * iStride - UV_WINDOWS_RADIUS;
93+ uint8_t* pCurLine1 = pStartPixels;
94+ uint8_t* pCurLine2 = pCurLine1 + iStride;
95+ uint8_t* pCurLine3 = pCurLine2 + iStride;
96+ uint8_t* pCurLine4 = pCurLine3 + iStride;
97+ uint8_t* pCurLine5 = pCurLine4 + iStride;
98+ uint8_t aSample[8];
99+
100+ for (int32_t i = 0; i < 8; i++) {
101+ sum = SUM_LINE1 ((pCurLine1 + i)) + SUM_LINE2 ((pCurLine2 + i)) + SUM_LINE3 ((pCurLine3 + i))
102+ + SUM_LINE2 ((pCurLine4 + i)) + SUM_LINE1 ((pCurLine5 + i));
103+ aSample[i] = (sum >> 6);
104+ pSample++;
105+ }
106+ WelsMemcpy (pSample - 8, aSample, 8);
107+}
108+
109+/***************************************************************************
110+edge of y/uv use a 3x3 Gauss filter, radius = 1:
111+1 2 1
112+2 4 2
113+1 2 1
114+***************************************************************************/
115+void Gauss3x3Filter (uint8_t* pSrc, int32_t iStride) {
116+ int32_t nSum = 0;
117+ uint8_t* pCurLine1 = pSrc - iStride - 1;
118+ uint8_t* pCurLine2 = pCurLine1 + iStride;
119+ uint8_t* pCurLine3 = pCurLine2 + iStride;
120+
121+ nSum = pCurLine1[0] + (pCurLine1[1] << 1) + pCurLine1[2] +
122+ (pCurLine2[0] << 1) + (pCurLine2[1] << 2) + (pCurLine2[2] << 1) +
123+ pCurLine3[0] + (pCurLine3[1] << 1) + pCurLine3[2];
124+ *pSrc = nSum >> 4;
125+}
126+
127+WELSVP_NAMESPACE_END

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t