Index: /branches/0.3-poznan-univ/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg
===================================================================
--- /branches/0.3-poznan-univ/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg	(revision 27)
+++ /branches/0.3-poznan-univ/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg	(revision 28)
@@ -97,5 +97,7 @@
 ALF                       : 1                                      # use adaptive loop filter
 ALFEncodePassReduction    : 0                                      # ALF encoding (0:original 16-pass, 1:one-pass, 2:two-pass)
-
+DBMP                      : 1                                      # use depth base motion prediction
+CUSkip                    : 1                                      # encode only disoccluded CUs in dependend views
+TDdQP                     : 1                                      # texture TU blocks QP param modification according to depth map's values
 
 #========== multiview coding tools ==========
@@ -113,5 +115,5 @@
 VSO                       : 1                                      # use of view synthesis optimization for depth coding
 MVI                       : 1                                      # motion parameter inheritance
-
+DepthPower                : -1                                     # nonlinear depth representation
 
 #========== view synthesis optimization (VSO) ==========
Index: /branches/0.3-poznan-univ/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg
===================================================================
--- /branches/0.3-poznan-univ/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg	(revision 27)
+++ /branches/0.3-poznan-univ/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg	(revision 28)
@@ -101,5 +101,7 @@
 ALF                       : 1                                      # use adaptive loop filter
 ALFEncodePassReduction    : 0                                      # ALF encoding (0:original 16-pass, 1:one-pass, 2:two-pass)
-
+DBMP                      : 1                                      # use depth base motion prediction
+CUSkip                    : 1                                      # encode only disoccluded CUs in dependend views
+TDdQP                     : 1                                      # texture TU blocks QP param modification according to depth map's values
 
 #========== multiview coding tools ==========
@@ -117,5 +119,5 @@
 VSO                       : 1                                      # use of view synthesis optimization for depth coding
 MVI                       : 1                                      # motion parameter inheritance
-
+DepthPower                : -1                                     # nonlinear depth representation
 
 #========== view synthesis optimization (VSO) ==========
@@ -123,2 +125,4 @@
                                                                    # VSO configuration string
 
+
+
Index: /branches/0.3-poznan-univ/build/HM_vc10.sln
===================================================================
--- /branches/0.3-poznan-univ/build/HM_vc10.sln	(revision 27)
+++ /branches/0.3-poznan-univ/build/HM_vc10.sln	(revision 28)
@@ -3,4 +3,7 @@
 # Visual Studio 2010
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TAppDecoder", "vc10\TAppDecoder_vc10.vcxproj", "{A7A515D9-E917-4706-BD5B-57DC6C78D612}"
+	ProjectSection(ProjectDependencies) = postProject
+		{2B298BE6-DFF0-4BD2-8F26-395FFE7F9EB4} = {2B298BE6-DFF0-4BD2-8F26-395FFE7F9EB4}
+	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TAppEncoder", "vc10\TAppEncoder_vc10.vcxproj", "{D759E4E1-D33A-4483-B57B-0FD248E022FE}"
Index: /branches/0.3-poznan-univ/build/HM_vc8.sln
===================================================================
--- /branches/0.3-poznan-univ/build/HM_vc8.sln	(revision 27)
+++ /branches/0.3-poznan-univ/build/HM_vc8.sln	(revision 28)
@@ -5,16 +5,17 @@
 	ProjectSection(ProjectDependencies) = postProject
 		{8783AD3A-A5CA-42B7-AAC4-A07EB845A684} = {8783AD3A-A5CA-42B7-AAC4-A07EB845A684}
+		{5E87AD84-AC4F-4336-B4EE-549CA210EE4A} = {5E87AD84-AC4F-4336-B4EE-549CA210EE4A}
+		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
+		{F8B77A48-AF6C-4746-A89F-B706ABA6AD94} = {F8B77A48-AF6C-4746-A89F-B706ABA6AD94}
 		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
-		{F8B77A48-AF6C-4746-A89F-B706ABA6AD94} = {F8B77A48-AF6C-4746-A89F-B706ABA6AD94}
-		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TAppEncoder", "vc8\TAppEncoder_vc8.vcproj", "{D759E4E1-D33A-4483-B57B-0FD248E022FE}"
 	ProjectSection(ProjectDependencies) = postProject
+		{8783AD3A-A5CA-42B7-AAC4-A07EB845A684} = {8783AD3A-A5CA-42B7-AAC4-A07EB845A684}
+		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
+		{47E90995-1FC5-4EE4-A94D-AD474169F0E1} = {47E90995-1FC5-4EE4-A94D-AD474169F0E1}
+		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
 		{5E87AD84-AC4F-4336-B4EE-549CA210EE4A} = {5E87AD84-AC4F-4336-B4EE-549CA210EE4A}
-		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
-		{47E90995-1FC5-4EE4-A94D-AD474169F0E1} = {47E90995-1FC5-4EE4-A94D-AD474169F0E1}
-		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
-		{8783AD3A-A5CA-42B7-AAC4-A07EB845A684} = {8783AD3A-A5CA-42B7-AAC4-A07EB845A684}
 	EndProjectSection
 EndProject
@@ -31,8 +32,8 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TAppRenderer", "vc8\TAppRenderer_vc8.vcproj", "{CE149235-A923-4BA7-B552-3A02287CD3E4}"
 	ProjectSection(ProjectDependencies) = postProject
+		{8783AD3A-A5CA-42B7-AAC4-A07EB845A684} = {8783AD3A-A5CA-42B7-AAC4-A07EB845A684}
+		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
+		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
 		{5E87AD84-AC4F-4336-B4EE-549CA210EE4A} = {5E87AD84-AC4F-4336-B4EE-549CA210EE4A}
-		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
-		{5280C25A-D316-4BE7-AE50-29D72108624F} = {5280C25A-D316-4BE7-AE50-29D72108624F}
-		{8783AD3A-A5CA-42B7-AAC4-A07EB845A684} = {8783AD3A-A5CA-42B7-AAC4-A07EB845A684}
 	EndProjectSection
 EndProject
Index: /branches/0.3-poznan-univ/build/HM_vc9.sln
===================================================================
--- /branches/0.3-poznan-univ/build/HM_vc9.sln	(revision 27)
+++ /branches/0.3-poznan-univ/build/HM_vc9.sln	(revision 28)
@@ -8,4 +8,5 @@
 		{78018D78-F890-47E3-A0B7-09D273F0B11D} = {78018D78-F890-47E3-A0B7-09D273F0B11D}
 		{D1E8A1C2-15DB-4C94-80E8-4F70CF0A2DC5} = {D1E8A1C2-15DB-4C94-80E8-4F70CF0A2DC5}
+		{457993C6-AE2C-4B9B-B5F9-71033279A0B9} = {457993C6-AE2C-4B9B-B5F9-71033279A0B9}
 	EndProjectSection
 EndProject
Index: /branches/0.3-poznan-univ/build/linux/common/makefile.base
===================================================================
--- /branches/0.3-poznan-univ/build/linux/common/makefile.base	(revision 27)
+++ /branches/0.3-poznan-univ/build/linux/common/makefile.base	(revision 28)
@@ -47,5 +47,5 @@
 # default cpp flags for all configurations
 #CPPFLAGS          = -Wall -fPIC $(DEFS) -I$(CURDIR)/$(INC_DIR) $(USER_INC_DIRS)
-CPPFLAGS          = -fPIC $(DEFS) -I$(CURDIR)/$(INC_DIR) $(USER_INC_DIRS) -Wall -Wshadow -Wno-sign-compare -Werror
+CPPFLAGS          = -fPIC $(DEFS) -I$(CURDIR)/$(INC_DIR) $(USER_INC_DIRS) -Wall -Wshadow -Wno-sign-compare
 
 ########## 
Index: /branches/0.3-poznan-univ/build/linux/lib/TLibCommon/makefile
===================================================================
--- /branches/0.3-poznan-univ/build/linux/lib/TLibCommon/makefile	(revision 27)
+++ /branches/0.3-poznan-univ/build/linux/lib/TLibCommon/makefile	(revision 28)
@@ -42,4 +42,5 @@
 			$(OBJ_DIR)/TComLoopFilter.o \
 			$(OBJ_DIR)/TComMotionInfo.o \
+            $(OBJ_DIR)/TComMP.o \
 			$(OBJ_DIR)/TComPattern.o \
 			$(OBJ_DIR)/TComPic.o \
Index: /branches/0.3-poznan-univ/build/linux/test/TAppDecoder/makefile
===================================================================
--- /branches/0.3-poznan-univ/build/linux/test/TAppDecoder/makefile	(revision 27)
+++ /branches/0.3-poznan-univ/build/linux/test/TAppDecoder/makefile	(revision 28)
@@ -41,13 +41,13 @@
 
 
-DYN_DEBUG_LIBS		= -lTLibDecoderd -lTLibCommond -lTLibVideoIOd -lTAppCommond
-DYN_DEBUG_PREREQS		= $(LIB_DIR)/libTLibDecoderd.a $(LIB_DIR)/libTLibCommond.a $(LIB_DIR)/libTLibVideoIOd.a $(LIB_DIR)/libTAppCommond.a
-STAT_DEBUG_LIBS		= -lTLibDecoderStaticd -lTLibCommonStaticd -lTLibVideoIOStaticd -lTAppCommonStaticd
-STAT_DEBUG_PREREQS		= $(LIB_DIR)/libTLibDecoderStaticd.a $(LIB_DIR)/libTLibCommonStaticd.a $(LIB_DIR)/libTLibVideoIOStaticd.a $(LIB_DIR)/libTAppCommonStaticd.a
+DYN_DEBUG_LIBS		= -lTLibDecoderd -lTLibCommond -lTLibVideoIOd -lTAppCommond -lTLibRendererd
+DYN_DEBUG_PREREQS	= $(LIB_DIR)/libTLibDecoderd.a $(LIB_DIR)/libTLibCommond.a $(LIB_DIR)/libTLibVideoIOd.a $(LIB_DIR)/libTAppCommond.a $(LIB_DIR)/libTLibRendererd.a
+STAT_DEBUG_LIBS		= -lTLibDecoderStaticd -lTLibCommonStaticd -lTLibVideoIOStaticd -lTAppCommonStaticd -lTLibRendererStaticd
+STAT_DEBUG_PREREQS	= $(LIB_DIR)/libTLibDecoderStaticd.a $(LIB_DIR)/libTLibCommonStaticd.a $(LIB_DIR)/libTLibVideoIOStaticd.a $(LIB_DIR)/libTAppCommonStaticd.a $(LIB_DIR)/libTLibRendererStaticd.a
 
-DYN_RELEASE_LIBS	= -lTLibDecoder -lTLibCommon -lTLibVideoIO -lTAppCommon
-DYN_RELEASE_PREREQS	= $(LIB_DIR)/libTLibDecoder.a $(LIB_DIR)/libTLibCommon.a $(LIB_DIR)/libTLibVideoIO.a $(LIB_DIR)/libTAppCommon.a
-STAT_RELEASE_LIBS	= -lTLibDecoderStatic -lTLibCommonStatic -lTLibVideoIOStatic -lTAppCommonStatic
-STAT_RELEASE_PREREQS	= $(LIB_DIR)/libTLibDecoderStatic.a $(LIB_DIR)/libTLibCommonStatic.a $(LIB_DIR)/libTLibVideoIOStatic.a $(LIB_DIR)/libTAppCommonStatic.a
+DYN_RELEASE_LIBS	= -lTLibDecoder -lTLibCommon -lTLibVideoIO -lTAppCommon -lTLibRenderer
+DYN_RELEASE_PREREQS	= $(LIB_DIR)/libTLibDecoder.a $(LIB_DIR)/libTLibCommon.a $(LIB_DIR)/libTLibVideoIO.a $(LIB_DIR)/libTAppCommon.a $(LIB_DIR)/libTLibRenderer.a
+STAT_RELEASE_LIBS	= -lTLibDecoderStatic -lTLibCommonStatic -lTLibVideoIOStatic -lTAppCommonStatic -lTLibRendererStatic
+STAT_RELEASE_PREREQS	= $(LIB_DIR)/libTLibDecoderStatic.a $(LIB_DIR)/libTLibCommonStatic.a $(LIB_DIR)/libTLibVideoIOStatic.a $(LIB_DIR)/libTAppCommonStatic.a $(LIB_DIR)/libTLibRendererStatic.a
 
 
Index: /branches/0.3-poznan-univ/build/vc10/TAppDecoder_vc10.vcxproj
===================================================================
--- /branches/0.3-poznan-univ/build/vc10/TAppDecoder_vc10.vcxproj	(revision 27)
+++ /branches/0.3-poznan-univ/build/vc10/TAppDecoder_vc10.vcxproj	(revision 28)
@@ -190,4 +190,12 @@
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="TLibRenderer_vc10.vcxproj">
+      <Project>{2b298be6-dff0-4bd2-8f26-395ffe7f9eb4}</Project>
+      <Private>true</Private>
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+      <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+      <LinkLibraryDependencies>true</LinkLibraryDependencies>
+      <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Index: /branches/0.3-poznan-univ/build/vc10/TLibCommon_vc10.vcxproj
===================================================================
--- /branches/0.3-poznan-univ/build/vc10/TLibCommon_vc10.vcxproj	(revision 27)
+++ /branches/0.3-poznan-univ/build/vc10/TLibCommon_vc10.vcxproj	(revision 28)
@@ -152,4 +152,5 @@
     <ClCompile Include="..\..\source\Lib\TLibCommon\TComLoopFilter.cpp" />
     <ClCompile Include="..\..\source\Lib\TLibCommon\TComMotionInfo.cpp" />
+    <ClCompile Include="..\..\source\Lib\TLibCommon\TComMP.cpp" />
     <ClCompile Include="..\..\source\Lib\TLibCommon\TComMVDRefData.cpp" />
     <ClCompile Include="..\..\source\Lib\TLibCommon\TComPattern.cpp" />
@@ -187,4 +188,5 @@
     <ClInclude Include="..\..\source\Lib\TLibCommon\TComLoopFilter.h" />
     <ClInclude Include="..\..\source\Lib\TLibCommon\TComMotionInfo.h" />
+    <ClInclude Include="..\..\source\Lib\TLibCommon\TComMP.h" />
     <ClInclude Include="..\..\source\Lib\TLibCommon\TComMv.h" />
     <ClInclude Include="..\..\source\Lib\TLibCommon\TComMVDRefData.h" />
Index: /branches/0.3-poznan-univ/build/vc10/TLibCommon_vc10.vcxproj.filters
===================================================================
--- /branches/0.3-poznan-univ/build/vc10/TLibCommon_vc10.vcxproj.filters	(revision 27)
+++ /branches/0.3-poznan-univ/build/vc10/TLibCommon_vc10.vcxproj.filters	(revision 28)
@@ -90,5 +90,8 @@
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\source\Lib\TLibCommon\TComWeightPrediction.cpp.cpp">
+    <ClCompile Include="..\..\source\Lib\TLibCommon\TComWeightPrediction.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\source\Lib\TLibCommon\TComMP.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -197,4 +200,7 @@
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\source\Lib\TLibCommon\TComMP.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
Index: /branches/0.3-poznan-univ/build/vc8/TLibCommon_vc8.vcproj
===================================================================
--- /branches/0.3-poznan-univ/build/vc8/TLibCommon_vc8.vcproj	(revision 27)
+++ /branches/0.3-poznan-univ/build/vc8/TLibCommon_vc8.vcproj	(revision 28)
@@ -81,4 +81,66 @@
 		</Configuration>
 		<Configuration
+			Name="Debug|x64"
+			OutputDirectory="$(SolutionDir)\vc8\$(PlatformName)\$(ConfigurationName)\$(RootNamespace)"
+			IntermediateDirectory="$(SolutionDir)\vc8\$(PlatformName)\$(ConfigurationName)\$(RootNamespace)"
+			ConfigurationType="4"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
 			Name="Release|Win32"
 			OutputDirectory="$(SolutionDir)\vc8\$(PlatformName)\$(ConfigurationName)\$(RootNamespace)"
@@ -145,66 +207,4 @@
 		</Configuration>
 		<Configuration
-			Name="Debug|x64"
-			OutputDirectory="$(SolutionDir)\vc8\$(PlatformName)\$(ConfigurationName)\$(RootNamespace)"
-			IntermediateDirectory="$(SolutionDir)\vc8\$(PlatformName)\$(ConfigurationName)\$(RootNamespace)"
-			ConfigurationType="4"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
-				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
 			Name="Release|x64"
 			OutputDirectory="$(SolutionDir)\vc8\$(PlatformName)\$(ConfigurationName)\$(RootNamespace)"
@@ -236,6 +236,6 @@
 				EnableIntrinsicFunctions="false"
 				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				PreprocessorDefinitions="WIN32;_LIB;_CRT_SECURE_NO_WARNINGS"
-				AdditionalIncludeDirectories="&quot;..\..\compat\msvc&quot;"
 				StringPooling="true"
 				RuntimeLibrary="0"
@@ -321,4 +321,8 @@
 			</File>
 			<File
+				RelativePath="..\..\source\Lib\TLibCommon\TComMP.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\source\Lib\TLibCommon\TComMVDRefData.cpp"
 				>
@@ -459,4 +463,8 @@
 			</File>
 			<File
+				RelativePath="..\..\source\Lib\TLibCommon\TComMP.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\source\Lib\TLibCommon\TComMv.h"
 				>
Index: /branches/0.3-poznan-univ/build/vc9/TLibCommon_vc9.vcproj
===================================================================
--- /branches/0.3-poznan-univ/build/vc9/TLibCommon_vc9.vcproj	(revision 27)
+++ /branches/0.3-poznan-univ/build/vc9/TLibCommon_vc9.vcproj	(revision 28)
@@ -324,4 +324,8 @@
 			</File>
 			<File
+				RelativePath="..\..\source\Lib\TLibCommon\TComMP.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\source\Lib\TLibCommon\TComMVDRefData.cpp"
 				>
@@ -462,4 +466,8 @@
 			</File>
 			<File
+				RelativePath="..\..\source\Lib\TLibCommon\TComMP.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\source\Lib\TLibCommon\TComMv.h"
 				>
Index: /branches/0.3-poznan-univ/source/App/TAppCommon/TAppComCamPara.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppCommon/TAppComCamPara.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppCommon/TAppComCamPara.cpp	(revision 28)
@@ -76,10 +76,10 @@
 
       radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
-      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
-      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
+      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ SizeOfLUT+1 ];
+      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ SizeOfLUT+1 ];
 
       raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
-      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
-      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
+      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ SizeOfLUT+1 ];
+      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ SizeOfLUT+1 ];
     }
   }
@@ -877,8 +877,22 @@
       radShiftParams[ uiSourceView][ uiTargetView ][ 1 ] = dOffset;
 
-      for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
-      {
+#if POZNAN_NONLINEAR_DEPTH
+      TComNonlinearDepthBackward cNonlinearDepthBwd(m_fDepthPower, (POZNAN_LUT_INCREASED_PRECISION) ? g_uiBitIncrement : 0, (POZNAN_LUT_INCREASED_PRECISION) ? g_uiBitIncrement : 0);
+#endif
+
+      for( UInt uiDepthValue = 0; uiDepthValue < SizeOfLUT; uiDepthValue++ )
+      {
+        Double  dDepthValue = (Double)uiDepthValue;
+        Int64   iDepthValue = (Int64)uiDepthValue;
+#if POZNAN_NONLINEAR_DEPTH
+        dDepthValue = cNonlinearDepthBwd(dDepthValue);
+        iDepthValue = (Int64)(dDepthValue+0.5);
+#endif
+#if POZNAN_LUT_INCREASED_PRECISION
+        dDepthValue /= (1<<g_uiBitIncrement);
+#endif
         // real-valued look-up tables
-        Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
+
+        Double  dShiftLuma      = ( dDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
         Double  dShiftChroma    = dShiftLuma / 2;
         radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
@@ -886,5 +900,8 @@
 
         // integer-valued look-up tables
-        Int64   iTempScale      = (Int64)uiDepthValue * iScale;
+        Int64   iTempScale      = iDepthValue * iScale;
+#if POZNAN_LUT_INCREASED_PRECISION
+        iTempScale >>= g_uiBitIncrement;
+#endif
         Int64   iTestScale      = ( iTempScale + iOffset       );   // for checking accuracy of camera parameters
         Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
@@ -899,8 +916,8 @@
       }
 
-      radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
-      radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
-      raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
-      raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
+      radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT-1 ];
+      radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT-1 ];
+      raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ SizeOfLUT-1 ];
+      raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ SizeOfLUT-1 ];
     }
   }
@@ -1235,5 +1252,9 @@
                       Char*  pchSynthViewNumbers,
                       std::vector<Int>* paiSynthViewNumbers,
-                      Int    iLog2Precision )
+                      Int    iLog2Precision
+#if POZNAN_NONLINEAR_DEPTH
+                      ,Float fDepthPower
+#endif
+                      )
 {
   //===== set miscellaneous variables =====
@@ -1243,4 +1264,8 @@
   m_uiCamParsCodedPrecision = uiCodedCamParsPrecision;
   m_iLog2Precision          = iLog2Precision;
+
+#if POZNAN_NONLINEAR_DEPTH
+  m_fDepthPower             = fDepthPower;
+#endif
 
   xReadCameraParameterFile( pchCfgFileName );
@@ -1460,4 +1485,30 @@
 }
 
+#if POZNAN_SYNTH
+Bool
+TAppComCamPara::getNearestBaseView( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft)
+{
+  riNearestViewIdx = 0;
+
+  Bool bDecencdingVN = ( m_aiSortedBaseViews.size() >= 2 && m_aiSortedBaseViews[ 0 ] > m_aiSortedBaseViews[ 1 ] );
+  Int  iFactor       = ( bDecencdingVN ? -1 : 1 );
+
+  if( ( m_aiBaseId2SortedId[iSynthViewIdx] - m_aiBaseId2SortedId[riNearestViewIdx] ) * iFactor  <= 0 )
+  {
+    rbRenderFromLeft = true;
+  }
+  else
+  {
+    rbRenderFromLeft = false;
+  }
+
+  riRelDistToLeft = 128; //Not used for now;
+
+  return true;
+}
+#endif
+
+
+
 Int TAppComCamPara::getRelDistLeft( Int iSynthViewIdx, Int iLeftViewIdx, Int iRightViewIdx )
 {
@@ -1474,2 +1525,15 @@
   return xGetViewId(m_aiRelSynthViewsNum, iRelNum );
 }
+
+
+#if POZNAN_MP
+Bool
+TAppComCamPara::isLeftView( Int iSynthViewIdx, Int iNearestViewIdx)
+{
+  Bool bDecencdingVN = ( m_aiSortedBaseViews.size() >= 2 && m_aiSortedBaseViews[ 0 ] > m_aiSortedBaseViews[ 1 ] );
+  Int  iFactor       = ( bDecencdingVN ? -1 : 1 );
+
+  if( ( m_aiBaseId2SortedId[iSynthViewIdx] - m_aiBaseId2SortedId[iNearestViewIdx] ) * iFactor  <= 0 ) return true;
+  else return false;
+}
+#endif
Index: /branches/0.3-poznan-univ/source/App/TAppCommon/TAppComCamPara.h
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppCommon/TAppComCamPara.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppCommon/TAppComCamPara.h	(revision 28)
@@ -104,4 +104,7 @@
   Int****             m_aiSynthViewShiftLUT;									///< Disparity LUT
 
+#if POZNAN_NONLINEAR_DEPTH
+  Float               m_fDepthPower;
+#endif
 
 protected:
@@ -161,5 +164,9 @@
                 Char*   pchSynthViewNumbers,
                 std::vector<Int>* paiSynthViewNumbers,
-                Int     iLog2Precision );
+                Int     iLog2Precision 
+#if POZNAN_NONLINEAR_DEPTH
+                ,Float  fDepthPower
+#endif
+                );
 
   Void init   ( UInt    uiInputBitDepth,
@@ -170,4 +177,7 @@
                 std::vector<Int>* paiSynthViewNumbers,
                 Int     iLog2Precision
+#if POZNAN_NONLINEAR_DEPTH
+                ,Float  fDepthPower
+#endif
               );
 
@@ -182,7 +192,15 @@
   Int                 synthRelNum2Idx           ( Int iRelNum );
   Bool getLeftRightBaseView( Int iSynthViewIdx, Int &riLeftViewIdx, Int &riRightViewIdx, Int &riRelDistToLeft, Bool& rbIsBaseView );
+#if POZNAN_SYNTH
+  Bool getNearestBaseView( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft);
+#endif
+
   Int                 getRelDistLeft            ( Int iSynthViewIdx, Int   iLeftViewIdx, Int iRightViewIdx );
   UInt                getCurFrameId             ()  { return m_iCurrentFrameId;   }
   static Void         convertNumberString       ( Char* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec );
+
+#if POZNAN_MP
+  Bool isLeftView( Int iSynthViewIdx, Int iNearestViewIdx);
+#endif
 
   // function for getting parameters and parameter arrays
Index: /branches/0.3-poznan-univ/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppDecoder/TAppDecTop.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppDecoder/TAppDecTop.cpp	(revision 28)
@@ -64,4 +64,8 @@
 //  m_iPOCLastDisplay  = -1;
   m_pScaleOffsetFile  = 0;
+
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
@@ -71,4 +75,8 @@
   
   m_apcBitstream->create( BITS_BUF_SIZE );
+
+#if POZNAN_MP
+  m_pcMP = new TComMP();
+#endif
 }
 
@@ -89,4 +97,8 @@
     free(m_pchReconFile);
   }
+
+#if POZNAN_MP
+  if(m_pcMP) { delete m_pcMP; m_pcMP = NULL; };
+#endif
 }
 
@@ -163,4 +175,8 @@
     if( eNalUnitType == NAL_UNIT_SPS )
     {
+#if POZNAN_SYNTH
+      if(cComSPS.getViewId()==0 && !cComSPS.isDepth()) // it should be called at first view at the begining of the stream
+        initRenderer(cComSPS);
+#endif
       if( cComSPS.isDepth() && (m_bUsingDepth==false) )  // expected not using depth, but bitstream are using depth
       {                                                     // know from sps
@@ -415,5 +431,19 @@
         if ( m_pchReconFile )
         {
+
+#if POZNAN_NONLINEAR_DEPTH
+          TComSPS* pcSPS = pcPic->getSlice(0)->getSPS();
+          TComPicYuv cPicPower;
+
+          //pcPic->getPicYuvRec()
+          cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); 
+
+          pcPic->getPicYuvRec()->nonlinearDepthBackward(&cPicPower, pcSPS->getDepthPower());
+
+          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write(&cPicPower, pcSPS->getPad());
+          cPicPower.destroy();		  
+#else
           m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
+#endif
         }
 
@@ -542,2 +572,164 @@
   return pcRefPic;
 }
+
+#if POZNAN_SYNTH
+Void TAppDecTop::initRenderer(TComSPS &cComSPS)
+{
+  m_cAvailabilityRenderer.init(cComSPS.getWidth(), cComSPS.getHeight(),true,0,LOG2_DISP_PREC_LUT,true, 0,0,0,0,0,6,4,1,0,6 );  //GT: simplest configuration
+}
+//*
+Void TAppDecTop::storeSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc, Bool bDepth)
+{
+  Int  iLeftViewIdx  = -1;
+  Int  iRightViewIdx = -1;
+  Int  iNearestViewIdx = -1;
+  Bool bRenderFromLeft;
+
+  Int iRelDistToLeft = 128;
+  if(iCoddedViewIdx==0) //First on View Coded List
+  {
+    //TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
+    return;
+  }
+  iNearestViewIdx = 0;
+  //bRenderFromLeft = iCoddedViewOrderIdx>0?true:false;
+  //bRenderFromLeft = iCoddedViewOrderIdx<0?true:false;
+  //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
+  bRenderFromLeft = iCoddedViewIdx>1?true:false;
+
+  m_cAvailabilityRenderer.setShiftLUTs(
+    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    iRelDistToLeft
+  );
+
+  TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, bDepth );
+
+  TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth();
+  TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail();
+  if(!pcPicYuvSynthView)
+  {
+    pcPic->addSynthesisBuffer();
+    pcPicYuvSynthView = pcPic->getPicYuvSynth();
+  }
+  if(!pcPicYuvAvailView)
+  {
+    pcPic->addAvailabilityBuffer();
+    pcPicYuvAvailView = pcPic->getPicYuvAvail();
+  }
+// usun i uzyj syntezy Krzysztofa tylko przesun ja przed dekodowanie tekstury to do
+  /*
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  if(!bDepth)
+  {
+  TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  if(!pcPicYuvSynthDepthView)
+  {
+    pcPic->addSynthesisDepthBuffer();
+    pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  }
+  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft );
+  
+#if POZNAN_OUTPUT_SYNTH
+      Char acFilenameBaseD[1024];
+      //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false");
+      ::sprintf( acFilenameBaseD,  "SynthInputDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
+      getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0);
+      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
+      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
+#endif
+   }
+#endif//*/
+
+  //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft );
+  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, bDepth )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft );
+
+  pcPicYuvAvailView->setBorderExtension( false );//Needed??
+  pcPicYuvAvailView->extendPicBorder();//Needed??
+
+#if POZNAN_OUTPUT_AVAILABLE_MAP
+  {
+  Char acFilenameBase[1024];
+  ::sprintf( acFilenameBase,  "Available_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx);
+  pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0);
+  }
+#endif
+#if POZNAN_OUTPUT_SYNTH
+  {
+  Char acFilenameBase[1024];
+  ::sprintf( acFilenameBase,  "Synth_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx );
+  pcPicYuvSynthView->dump(acFilenameBase, iCurPoc!=0);
+  }
+#endif
+}
+#endif
+
+//*
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Void TAppDecTop::storeDepthSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc)
+{
+  Int  iLeftViewIdx  = -1;
+  Int  iRightViewIdx = -1;
+  Int  iNearestViewIdx = -1;
+  Bool bRenderFromLeft;
+
+  Int iRelDistToLeft = 128;
+  if(iCoddedViewIdx==0) //First on View Coded List
+  {
+    //TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
+    return;
+  }
+  iNearestViewIdx = 0;
+  //bRenderFromLeft = iCoddedViewOrderIdx>0?true:false;
+  //bRenderFromLeft = iCoddedViewOrderIdx<0?true:false;
+  //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
+  bRenderFromLeft = iCoddedViewIdx>1?true:false;
+
+  m_cAvailabilityRenderer.setShiftLUTs(
+    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    iRelDistToLeft
+  );
+
+  TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
+
+  TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  if(!pcPicYuvSynthDepthView)
+  {
+    pcPic->addSynthesisDepthBuffer();
+    pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  }
+  
+  Int   iWidth        = pcPicYuvSynthDepthView->getWidth      ();
+  Int   iHeight       = pcPicYuvSynthDepthView->getHeight     ();
+  UInt  uiMaxCuWidth  = pcPicYuvSynthDepthView->getMaxCuWidth ();
+  UInt  uiMaxCuHeight = pcPicYuvSynthDepthView->getMaxCuHeight();
+  UInt  uiMaxCuDepth  = pcPicYuvSynthDepthView->getMaxCuDepth ();
+
+  TComPicYuv* pcPicYuvAvailView = new TComPicYuv;
+  pcPicYuvAvailView->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
+
+  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft );
+  
+  pcPicYuvAvailView->destroy();
+  delete pcPicYuvAvailView;
+
+#if POZNAN_OUTPUT_SYNTH
+      Char acFilenameBaseD[1024];
+      //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false");
+      ::sprintf( acFilenameBaseD,  "SynthInputDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
+      getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0);
+      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx );
+      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
+#endif
+  
+}
+#endif//*/
Index: /branches/0.3-poznan-univ/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppDecoder/TAppDecTop.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppDecoder/TAppDecTop.h	(revision 28)
@@ -52,5 +52,12 @@
 #include "../../Lib/TLibCommon/TComDepthMapGenerator.h"
 #include "../../Lib/TLibDecoder/TDecTop.h"
+#if POZNAN_SYNTH
+#include "../../Lib/TLibRenderer/TRenTop.h"
+#endif
 #include "TAppDecCfg.h"
+
+#if POZNAN_MP
+#include "../../Lib/TLibCommon/TComMP.h"
+#endif
 
 // ====================================================================================================================
@@ -87,4 +94,12 @@
 #endif
 
+#if POZNAN_SYNTH
+  TRenTop                         m_cAvailabilityRenderer;
+#endif
+
+#if POZNAN_MP
+  TComMP*						  m_pcMP;
+#endif
+
 public:
   TAppDecTop();
@@ -97,5 +112,14 @@
   Void  startUsingDepth() ;
 
-// GT FIX
+#if POZNAN_SYNTH
+  Void  initRenderer(TComSPS &cComSPS);
+  Void  storeSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx,Int iCurPoc,Bool bDepth);
+#endif
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Void storeDepthSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc);
+#endif
+
+ // GT FIX
   std::vector<TComPic*> getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepth );
   TComPic* getPicFromView( Int iViewIdx, Int iPoc, bool bDepth );
@@ -106,4 +130,8 @@
   TComAUPicAccess*  getAUPicAccess() { return &m_cAUPicAccess; }
   TDecTop*          getDecTop0    () { return m_acTDecTopList[0]; }
+#endif
+
+#if POZNAN_MP
+  TComMP* getMP() { return m_pcMP; }
 #endif
 
Index: /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 28)
@@ -341,4 +341,12 @@
 #endif
 
+#if POZNAN_DBMP
+  ("DBMP",  m_uiDBMP,    (UInt)0, "usage of Depth-Based Motion Prediction" )
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  ("CUSkip",  m_uiUseCUSkip,    (UInt)1, "encode only disoccluded CUs in dependend view" )
+#endif
+
   ("QpChangeFrame", m_iQpChangeFrame, PicOrderCnt(0), "start frame for QP change")
   ("QpChangeOffsetVideo", m_iQpChangeOffsetVideo, 0, "QP change offset for video")
@@ -350,4 +358,16 @@
 #endif
 #endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  ("TDdQP", m_bUseTexDqpAccordingToDepth, false, "texture TU blocks QP param modification according to depth map's values")
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+  ("TDdQPOffset",              m_dTexDqpAccordingToDepthOffset,       (Double)(-2.6), "texture block QP changing tool based on coresponding depth block values - offset parameter" )
+  ("TDdQPMul",                 m_dTexDqpAccordingToDepthMul,          (Double)(1),    "texture block QP changing tool based on coresponding depth block values - multiplicative parameter" )
+  ("TDdQPTopBottomRow",        m_iTexDqpAccordingToDepthTopBottomRow, (Int)2,         "texture block QP changing tool - top and bottom CU rows delta QP parameter" )
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+  ("DepthPower,-dpow",    m_fDepthPower,      (Double)1.0, "Depth power value (for non-linear processing)")
+#endif
+
 
   /* Compatability with old style -1 FOO or -0 FOO options. */
@@ -437,4 +457,21 @@
 #endif
 
+#if POZNAN_NONLINEAR_DEPTH
+if (m_fDepthPower<=0) 
+  {
+    Float fDepthQP = m_adQP[ m_adQP.size()  < 2 ? 0 : 1];
+    m_fDepthPower = (fDepthQP-30) *0.25/20.0 + 1.25;
+    if (m_fDepthPower<=1.0) m_fDepthPower = 1.0;
+    // QP = 30 = 1.25
+    // QP = 50 = 1.5
+    if (m_fDepthPower>=1.66) m_fDepthPower = 1.66;
+  };
+
+#if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE
+  m_fDepthPower = dequantizeDepthPower(quantizeDepthPower((Float)m_fDepthPower));
+#endif
+
+#endif
+
   xCleanUpVectors();
 
@@ -516,5 +553,9 @@
                                       NULL,
                                       m_cRenModStrParser.getSynthViews(),
-                                      LOG2_DISP_PREC_LUT );
+                                      LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+                                      ,m_fDepthPower
+#endif
+                                      );
 }
 else if ( m_bUseVSO && m_uiVSOMode != 4 )
@@ -529,5 +570,9 @@
                                       m_pchVSOConfig,
                                       NULL,
-                                      LOG2_DISP_PREC_LUT );
+                                      LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+                                      ,m_fDepthPower
+#endif                                      
+                                      );
 }
 else
@@ -542,5 +587,9 @@
     NULL,
     NULL,
-    LOG2_DISP_PREC_LUT );
+    LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+    ,m_fDepthPower
+#endif    
+    );
 }
 #else
@@ -554,5 +603,9 @@
     NULL,
     NULL,
-    LOG2_DISP_PREC_LUT );
+    LOG2_DISP_PREC_LUT 
+#if POZNAN_NONLINEAR_DEPTH                                      
+    ,m_fDepthPower
+#endif    
+    );
 #endif
 
@@ -665,4 +718,12 @@
 #endif
 
+#if POZNAN_DBMP
+  xConfirmPara    ( m_uiDBMP > 1,													"DBMP must be less than or equal to 1" );
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  xConfirmPara    ( m_uiUseCUSkip > 1,												"CU-Skip must be less than or equal to 1" );
+#endif
+
 #if HHI_INTERVIEW_SKIP
   xConfirmPara    ( m_uiInterViewSkip > 1,                                        "RenderingSkipMode > 1 not supported" );
@@ -933,4 +994,49 @@
 #if MTK_SAO
 #endif
+
+#if POZNAN_MP
+  printf("POZNAN_MP(1){ ");
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  printf("dmg=1 ");
+#else
+  printf("dmg=0 ");
+#endif
+
+#if POZNAN_MP_FILL
+  printf("fill=%d ",POZNAN_MP_FILL_TYPE);
+#else
+  printf("fill=- ");
+#endif
+
+#if POZNAN_DBMP
+  printf("DBMP:%d ", m_uiDBMP);
+  if(m_uiDBMP)
+  {    
+	printf("cand=%d ",POZNAN_DBMP_MERGE_POS);
+#if POZNAN_DBMP_CALC_PRED_DATA
+	printf("pr=1 ");
+#else
+	printf("pr=0 ");
+#endif
+#if POZNAN_DBMP_COMPRESS_ME_DATA
+	printf("comp=1 ");
+#else
+	printf("comp=0 ");
+#endif
+#if POZNAN_DBMP_USE_IN_NONANCHOR_PIC_ONLY
+	printf("na=1 ");
+#else
+	printf("na=0 ");
+#endif
+  }
+#endif
+  printf("} ");
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  printf("CU-Skip:%d ", m_uiUseCUSkip);
+#endif
+
   printf("\n");
   printf("TOOL CFG VIDEO  : ");
@@ -938,4 +1044,8 @@
   printf("SAO:%d ", (m_abUseSAO [0] ? 1 : 0));
   printf("RDQ:%d ", (m_abUseRDOQ[0] ? 1 : 0) );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  printf("TDdQP:%d ", m_bUseTexDqpAccordingToDepth);
+#endif
+
   printf("\n");
 
@@ -952,4 +1062,7 @@
 #if HHI_MPI
   printf("MVI:%d ", m_bUseMVI ? 1 : 0 );
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+  printf("DepthPower:%f ", m_fDepthPower);
 #endif
   printf("\n");
Index: /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h	(revision 28)
@@ -178,4 +178,12 @@
 #endif
 
+#if POZNAN_DBMP
+  UInt      m_uiDBMP;							                            ///< using Depth-Based Motion Prediction
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  UInt      m_uiUseCUSkip;                                       ///< using CU-Skip - Encode only disoccluded CUs in dependend view
+#endif
+
 #if HHI_INTERVIEW_SKIP
   UInt      m_uiInterViewSkip;                            ///< usage of interview skip mode ( do not transmit residual)
@@ -246,4 +254,7 @@
 #endif
 
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Bool      m_bUseTexDqpAccordingToDepth;                       ///< flag for using texture QP param modyfication according to depth map's values
+#endif
   // internal member functions
   Void  xSetGlobal      ();                                   ///< set global variables
@@ -271,4 +282,15 @@
   TRenModSetupStrParser       m_cRenModStrParser;
 #endif
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+  Double                      m_dTexDqpAccordingToDepthOffset;
+  Double                      m_dTexDqpAccordingToDepthMul;
+  Int                         m_iTexDqpAccordingToDepthTopBottomRow;
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+  Double    m_fDepthPower;									  ///< Depth power value
+#endif
+
 public:
 
Index: /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp	(revision 28)
@@ -141,4 +141,8 @@
     m_acTEncTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
 
+#if POZNAN_NONLINEAR_DEPTH
+    m_acTEncTopList[iViewIdx]->setDepthPower                   ( (Float)m_fDepthPower );
+#endif
+
 #if HHI_VSO
     m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); //GT: might be enabled later for VSO Mode 4
@@ -167,4 +171,11 @@
 #endif
 
+#if POZNAN_DBMP
+	m_acTEncTopList[iViewIdx]->setDBMP                           ( m_uiDBMP );
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+	m_acTEncTopList[iViewIdx]->setUseCUSkip                         ( m_uiUseCUSkip );
+#endif
 
 #if HHI_INTERVIEW_SKIP
@@ -222,4 +233,14 @@
     m_acTEncTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo );
     m_acTEncTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth );
+
+    
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_acTEncTopList[iViewIdx]->setUseTexDqpAccordingToDepth      ( m_bUseTexDqpAccordingToDepth );
+#endif
+ #if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+    m_acTEncTopList[iViewIdx]->setTexDqpAccordingToDepthOffset( m_dTexDqpAccordingToDepthOffset );
+    m_acTEncTopList[iViewIdx]->setTexDqpAccordingToDepthMul( m_dTexDqpAccordingToDepthMul );
+    m_acTEncTopList[iViewIdx]->setTexDqpAccordingToDepthTopBottomRow( m_iTexDqpAccordingToDepthTopBottomRow );  
+#endif
   }
   if( m_bUsingDepthMaps )
@@ -382,4 +403,13 @@
       m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
 #endif
+#if POZNAN_DBMP
+      m_acTEncDepthTopList[iViewIdx]->setDBMP                        ( m_uiDBMP );
+#endif
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+	    m_acTEncDepthTopList[iViewIdx]->setUseCUSkip                      ( m_uiUseCUSkip );
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+      m_acTEncDepthTopList[iViewIdx]->setDepthPower                   ( (Float)m_fDepthPower );
+#endif
 
       m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
@@ -435,7 +465,22 @@
 #endif
 
+#if POZNAN_SYNTH
+  //m_cAvailabilityRenderer.init(m_iSourceWidth, m_iSourceHeight,true,0,0,true, 0,0,0,0,0,0,0,1,0,0 );  //GT: simplest configuration
+  m_cAvailabilityRenderer.init(m_iSourceWidth, m_iSourceHeight,true,0,LOG2_DISP_PREC_LUT,true, 0,0,0,0,0,6,4,1,0,6 );  //GT: simplest configuration
+#endif
+
 #if HHI_INTERVIEW_SKIP
   m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 );
 #endif
+
+#if POZNAN_MP
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  m_pcMP = new TComMP(m_iSourceHeight, m_iSourceWidth);
+#else
+  //m_pcMP = new TComMP(m_iSourceHeight, m_iSourceWidth, &m_cCameraData);
+  m_pcMP = new TComMP(m_iSourceHeight, m_iSourceWidth, m_cCameraData.getBaseViewShiftLUTI());
+#endif
+#endif
+
 }
 
@@ -485,4 +530,8 @@
 
   m_cTVideoIOBitsFile.closeBits();
+
+#if POZNAN_MP
+  if (m_pcMP) { delete m_pcMP; m_pcMP=NULL; };
+#endif
 
 #if HHI_VSO
@@ -640,4 +689,7 @@
         {
           m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps );
+#if POZNAN_NONLINEAR_DEPTH
+		      pcPdmDepthOrg->nonlinearDepthForward(pcPdmDepthOrg, m_fDepthPower);		  
+#endif
         }
 #endif
@@ -661,4 +713,7 @@
           // read input YUV file
           m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad  ) ;
+#if POZNAN_NONLINEAR_DEPTH
+		      pcDepthPicYuvOrg->nonlinearDepthForward(pcDepthPicYuvOrg, m_fDepthPower);		  
+#endif
           bDepthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
           bDepthEos[iViewIdx] = ( m_iDepthFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ?    true : bDepthEos[iViewIdx]   );
@@ -692,4 +747,18 @@
     for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )     // Start encoding
     {
+#if POZNAN_SYNTH
+      if( m_uiUseCUSkip )
+      {
+        xStoreSynthPicsInBuffer(iViewIdx,false);
+      }
+#endif
+            //*
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      if(m_bUseTexDqpAccordingToDepth)
+      {
+        xStoreDepthSynthPicsInBuffer(iViewIdx);
+      }
+#endif
+      //*/
       bool bThisViewContinueReadingPics = bContinueReadingPics[iViewIdx];
       m_acTEncTopList[iViewIdx]->encode( bEos[iViewIdx], m_cListPicYuvRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingPics );
@@ -708,4 +777,10 @@
       if( m_bUsingDepthMaps )
       {
+#if POZNAN_SYNTH
+        if( m_uiUseCUSkip )
+        {
+          xStoreSynthPicsInBuffer(iViewIdx,true);
+        }
+#endif
         bool bThisViewContinueReadingDepthPics = bContinueReadingDepthPics[iViewIdx];
         m_acTEncDepthTopList[iViewIdx]->encode( bDepthEos[iViewIdx], m_cListPicYuvDepthRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingDepthPics );
@@ -928,4 +1003,17 @@
   {
     riNextPocToDump++;
+#if POZNAN_NONLINEAR_DEPTH
+    if(isDepth)
+    {
+      TComPicYuv *pcPicOrg = i->second;
+      TComPicYuv *pcPicPow = new TComPicYuv; 
+      //pcPicYuvRec->createCompatibleAs(*iterPicYuvRec);
+      pcPicPow->create( pcPicOrg->getWidth(), pcPicOrg->getHeight(), pcPicOrg->getMaxCuWidth(), pcPicOrg->getMaxCuHeight(), pcPicOrg->getMaxCuDepth() );
+      //cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); 
+      pcPicOrg->nonlinearDepthBackward(pcPicPow, m_fDepthPower);		
+      rpcTVideoIOYuvReconFile->write( pcPicPow, m_aiPad );
+// to do destroy pcPicow
+    } else
+#endif
     rpcTVideoIOYuvReconFile->write( i->second, m_aiPad );
     rcMap.erase( i );
@@ -1177,4 +1265,172 @@
 #endif
 
+#if POZNAN_SYNTH
+Void TAppEncTop::xStoreSynthPicsInBuffer(Int iCoddedViewIdx,Bool bDepth)
+{
+  Int iCurPoc;
+  if(bDepth)
+  {
+    iCurPoc = m_acTEncDepthTopList[ iCoddedViewIdx ]->getNextFrameId();
+    if (!(m_acTEncDepthTopList[ iCoddedViewIdx ]->currentPocWillBeCoded())) return;
+  }
+  else
+  {
+    iCurPoc = m_acTEncTopList[ iCoddedViewIdx ]->getNextFrameId();
+    if (!(m_acTEncTopList[ iCoddedViewIdx ]->currentPocWillBeCoded())) return;
+  }
+  
+  Int iNumberOfReferenceViews = 0;
+  Int  iNearestViewIdx = -1;
+  Bool bRenderFromLeft;
+
+  Int iRelDistToLeft;
+  if(iCoddedViewIdx==0) //First on View Coded List
+  {
+    //TComPic* pcPic = xGetPicFromView( iCoddedViewIdx, iCurPoc, false );
+    return;
+  }
+  m_cCameraData.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
+
+  m_cAvailabilityRenderer.setShiftLUTs(
+    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    iRelDistToLeft
+  );
+    
+
+  TComPicYuv* pcPicYuvERView = new TComPicYuv;
+  pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
+
+  TComPic* pcPic = xGetPicFromView( iCoddedViewIdx, iCurPoc, bDepth );
+  pcPic->addSynthesisBuffer();
+  pcPic->addAvailabilityBuffer();
+// usun to i wykorzystaj synteze która robi krzysztof dla glebi - tylko najpierw ja przeson przed kodowanie tekstury //to do
+  /*
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      if(!bDepth)
+      {
+      pcPic->addSynthesisDepthBuffer();
+      TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+      m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPic->getPicYuvAvail(), bRenderFromLeft );
+#if POZNAN_OUTPUT_SYNTH
+      Char acFilenameBaseD[1024];
+      //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false");
+      ::sprintf( acFilenameBaseD,  "SynthInputDepth_%s_V%d.yuv", ( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+      xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0);
+      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
+#endif
+      }
+#endif//*/
+  TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth();
+  TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail();
+  
+  //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft );
+  m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, bDepth )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft );
+      
+  pcPicYuvAvailView->setBorderExtension( false );//Needed??
+  pcPicYuvAvailView->extendPicBorder();//Needed??
+
+  pcPicYuvSynthView->setBorderExtension( false );//Needed??
+  pcPicYuvSynthView->extendPicBorder();//Needed??
+
+  //TComPic* pcPicDepth = xGetPicFromView( iCoddedViewIdx, iCurPoc, true );
+  //pcPicDepth->addAvailabilityBuffer();
+  //pcPicDepth->addSynthesisBuffer();
+  //pcPicYuvAvailView->copyToPic(pcPicDepth->getPicYuvAvail());
+      
+#if POZNAN_OUTPUT_AVAILABLE_MAP
+  {
+  Char acFilenameBase[1024];
+  ::sprintf( acFilenameBase,  "Available_%s_%s_V%d.yuv", (bDepth?"Depth":"Tex"),( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+  pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0);
+  }
+#endif
+#if POZNAN_OUTPUT_SYNTH
+  {
+  Char acFilenameBase[1024];
+  ::sprintf( acFilenameBase,  "Synth_%s_%s_V%d.yuv", (bDepth?"Depth":"Tex"),( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+  pcPicYuvERView->dump(acFilenameBase, iCurPoc!=0);
+  }
+#endif
+
+      //Usun pcPicYuvERView i inne bufforki
+}
+#endif
+
+//*
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Void TAppEncTop::xStoreDepthSynthPicsInBuffer(Int iCoddedViewIdx)
+{
+  Int  iLeftViewIdx  = -1;
+  Int  iRightViewIdx = -1;
+  Int  iNearestViewIdx = -1;
+  Bool bRenderFromLeft;
+
+  Int iCurPoc = m_acTEncTopList[ iCoddedViewIdx ]->getNextFrameId();
+  if (!(m_acTEncTopList[ iCoddedViewIdx ]->currentPocWillBeCoded())) return;
+
+  Int iRelDistToLeft = 128;
+  if(iCoddedViewIdx==0) //First on View Coded List
+  {
+    //TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
+    return;
+  }
+  iNearestViewIdx = 0;
+  //bRenderFromLeft = iCoddedViewOrderIdx>0?true:false;
+  //bRenderFromLeft = iCoddedViewOrderIdx<0?true:false;
+  //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft);
+  bRenderFromLeft = iCoddedViewIdx>1?true:false;
+
+  m_cAvailabilityRenderer.setShiftLUTs(
+    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    m_cCameraData.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx],
+    iRelDistToLeft
+  );
+
+  TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false );
+
+  TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  if(!pcPicYuvSynthDepthView)
+  {
+    pcPic->addSynthesisDepthBuffer();
+    pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth();
+  }
+  
+  Int   iWidth        = pcPicYuvSynthDepthView->getWidth      ();
+  Int   iHeight       = pcPicYuvSynthDepthView->getHeight     ();
+  UInt  uiMaxCuWidth  = pcPicYuvSynthDepthView->getMaxCuWidth ();
+  UInt  uiMaxCuHeight = pcPicYuvSynthDepthView->getMaxCuHeight();
+  UInt  uiMaxCuDepth  = pcPicYuvSynthDepthView->getMaxCuDepth ();
+
+  TComPicYuv* pcPicYuvAvailView = new TComPicYuv;
+  pcPicYuvAvailView->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
+
+  m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft );
+  
+  pcPicYuvAvailView->destroy();
+  delete pcPicYuvAvailView;
+
+#if POZNAN_OUTPUT_SYNTH
+      Char acFilenameBaseD[1024];
+      //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false");
+      ::sprintf( acFilenameBaseD,  "SynthInputDepth_%s_V%d.yuv", ( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+      getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0);
+      ::sprintf( acFilenameBaseD,  "SynthDepth_%s_V%d.yuv", ( false ? "Dec" : "Enc" ),iCoddedViewIdx );
+      pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0);
+#endif
+  
+}
+#endif//*/
+
+
 #if HHI_INTERVIEW_SKIP
 Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap )
Index: /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.h	(revision 28)
@@ -51,4 +51,8 @@
 //GT VSO end
 
+#if POZNAN_MP
+#include "../../Lib/TLibCommon/TComMP.h"
+#endif	
+
 // ====================================================================================================================
 // Class definition
@@ -92,4 +96,11 @@
 #endif
 
+#if POZNAN_SYNTH
+  TRenTop                     m_cAvailabilityRenderer;
+#endif
+
+#if POZNAN_MP
+  TComMP*				  m_pcMP;
+#endif
 protected:
   // initialization
@@ -145,4 +156,8 @@
 #endif
 
+#if POZNAN_MP
+  TComMP* getMP() {return m_pcMP;}
+#endif
+
 #if HHI_VSO
 private:
@@ -155,4 +170,15 @@
 #endif
   
+
+#if POZNAN_SYNTH
+private:
+  Void  xStoreSynthPicsInBuffer(Int iCoddedViewIdx, Bool bDepth);
+#endif
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+private:
+  Void xStoreDepthSynthPicsInBuffer(Int iCoddedViewIdx);
+#endif
+
 };// END CLASS DEFINITION TAppEncTop
 
Index: /branches/0.3-poznan-univ/source/App/TAppRenderer/TAppRendererCfg.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 28)
@@ -186,5 +186,9 @@
   {
     m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
-      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
+      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, NULL, m_iLog2SamplingFactor+m_iShiftPrecision
+#if POZNAN_NONLINEAR_DEPTH      
+      ,1.0f 
+#endif
+      );
     m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
     m_iNumberOfOutputViews = m_iNumberOfInputViews - 1;
@@ -205,10 +209,18 @@
 
   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
-      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision );
+      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, NULL, piaTempViews, m_iLog2SamplingFactor+m_iShiftPrecision
+#if POZNAN_NONLINEAR_DEPTH
+      , 1.0f 
+#endif
+      );
   }
   else
   {
   m_cCameraData.init( MAX_INPUT_VIEW_NUM, uiInputBitDepth, uiCamParPrecision, (UInt)m_iFrameSkip, (UInt)m_iFramesToBeRendered,
-      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision );
+      m_pchCameraParameterFile, m_pchBaseViewCameraNumbers, m_pchSynthViewCameraNumbers, NULL, m_iLog2SamplingFactor+m_iShiftPrecision
+#if POZNAN_NONLINEAR_DEPTH
+      ,1.0f 
+#endif
+      );
   m_iNumberOfOutputViews = (Int) m_cCameraData.getSynthViewNumbers().size();
   m_iNumberOfInputViews  = (Int) m_cCameraData.getBaseViewNumbers() .size();
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h	(revision 28)
@@ -138,8 +138,14 @@
 
 
-#if ( HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED )
+#if ( HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED || POZNAN_MP_USE_DEPTH_MAP_GENERATION)
 #define DEPTH_MAP_GENERATION        1
 #else
 #define DEPTH_MAP_GENERATION        0
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+#define POZNAN_LUT_INCREASED_PRECISION 0 // 1 //to do
+#else
+#define POZNAN_LUT_INCREASED_PRECISION 0
 #endif
 
@@ -174,6 +180,30 @@
 #define OUTPUT_RESIDUAL_PICTURES          0         // output residual pictures (for debugging)
 
-#define HHI_MPI_MERGE_POS                     0         // position of mvi in merge list (0..5)
-
+#define HHI_MPI_MERGE_POS                 0         // position of mvi in merge list (0..5)
+
+// ====================================================================================================================
+// POZNAN DEFINE SECTION
+// ====================================================================================================================
+#define POZNAN_OUTPUT_AVAILABLE_MAP       0           // output available map (for debugging)
+#define POZNAN_OUTPUT_SYNTH               0           // output synthesised view (for debugging)
+
+#if POZNAN_DBMP
+#define POZNAN_DBMP_MERGE_POS             0         // position of DBMP candidate in merge list for coding (0..6) - overwrites PDM_MERGE_POS settings, is overwritten by HHI_MPI_MERGE_POS settings!!!
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+inline UChar quantizeDepthPower(Float fDepthPower)
+{
+  Int r = (Int) ( (fDepthPower-1.0f)*128.0f + 0.5f);
+  if (r<=0) return 0;
+  if (r>255) r=255;  
+  return r;
+};
+
+inline Float dequantizeDepthPower(Int iDepthQuant)
+{
+  return iDepthQuant/128.0f + 1.0f;  
+};
+#endif
 
 // ====================================================================================================================
@@ -186,5 +216,13 @@
 #define Clip(x)                     ( Min(g_uiIBDI_MAX, Max( 0, (x)) ) )                              ///< clip with bit-depth range
 #define Clip3( MinVal, MaxVal, a)   ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) )  ///< general min/max clip
-#define RemoveBitIncrement(x)       ( (x + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
+#define RemoveBitIncrement(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
+
+#if POZNAN_LUT_INCREASED_PRECISION
+#define RemoveBitIncrementLUT(x)       (x)     ///< Remove Bit increment
+#define SizeOfLUT                      (256 << g_uiBitIncrement)  
+#else
+#define SizeOfLUT                      256
+#define RemoveBitIncrementLUT(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
+#endif
 
 #define DATA_ALIGN                  1                                                                 ///< use 32-bit aligned malloc/free
@@ -216,5 +254,10 @@
 #define AMVP_MAX_NUM_CANDS          6           ///< max number of final candidates
 // MERGE
+#if POZNAN_DBMP
+#define MRG_MAX_NUM_CANDS           7
+#define POZNAN_DBMP_MRG_CAND	MRG_MAX_NUM_CANDS-1			// position of DBMP candidate in merge list (0..6)
+#else
 #define MRG_MAX_NUM_CANDS           6
+#endif
 
 // Reference memory management
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/ContextTables.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/ContextTables.h	(revision 28)
@@ -53,5 +53,9 @@
 #define NUM_MERGE_FLAG_EXT_CTX        3       ///< number of context models for merge flag of merge extended
 #define NUM_MERGE_IDX_EXT_CTX         4       ///< number of context models for merge index of merge extended
+#if POZNAN_DBMP
+#define NUM_MV_MERGE_IDX_EXT_CTX      6       ///< number of context models for merge index of merge extended
+#else
 #define NUM_MV_MERGE_IDX_EXT_CTX      5       ///< number of context models for merge index of merge extended
+#endif
 #define NUM_RES_PRED_FLAG_CTX         3       ///< number of context for residual prediction flag     
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.cpp	(revision 28)
@@ -187,4 +187,9 @@
     m_acCUMvField[1].create( uiNumPartition );
     
+#if POZNAN_DBMP_CALC_PRED_DATA
+    m_acCUMvField2nd[0].create( uiNumPartition );
+    m_acCUMvField2nd[1].create( uiNumPartition );
+#endif
+    
 #if HHI_DMM_WEDGE_INTRA
     m_puiWedgeFullTabIdx       = (UInt*)xMalloc(UInt, uiNumPartition);
@@ -210,4 +215,9 @@
     m_acCUMvField[0].setNumPartition(uiNumPartition );
     m_acCUMvField[1].setNumPartition(uiNumPartition );
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+    m_acCUMvField2nd[0].setNumPartition(uiNumPartition );
+    m_acCUMvField2nd[1].setNumPartition(uiNumPartition );
+#endif
   }
   
@@ -296,4 +306,10 @@
     if ( m_piContourPredTexDeltaDC2  ) { xFree(m_piContourPredTexDeltaDC2);  m_piContourPredTexDeltaDC2  = NULL; }
 #endif    
+    
+#if POZNAN_DBMP_CALC_PRED_DATA
+    m_acCUMvField2nd[0].destroy();
+    m_acCUMvField2nd[1].destroy();
+#endif
+
   }
   
@@ -388,4 +404,9 @@
   m_acCUMvField[0].clearMvField();
   m_acCUMvField[1].clearMvField();
+  
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[0].clearMvField();
+  m_acCUMvField2nd[1].clearMvField();
+#endif
   
   UInt uiTmp = m_puhWidth[0]*m_puhHeight[0];
@@ -508,4 +529,9 @@
   m_acCUMvField[1].clearMvField();
 
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[0].clearMvField();
+  m_acCUMvField2nd[1].clearMvField();
+#endif
+
 #if HHI_DMM_WEDGE_INTRA
   memset( m_puiWedgeFullTabIdx,  0, iSizeInUInt   );
@@ -617,4 +643,9 @@
   m_uiEntropySliceStartCU   = pcCU->getEntropySliceStartCU();
 
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[0].clearMvField();
+  m_acCUMvField2nd[1].clearMvField();
+#endif
+
 #if HHI_DMM_WEDGE_INTRA
   memset( m_puiWedgeFullTabIdx,  0, iSizeInUInt   );
@@ -719,4 +750,14 @@
   m_acCUMvField[1].setMvdPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getMvd()    + uiPart);
   m_acCUMvField[1].setRefIdxPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx() + uiPart);
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[0].setMvPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getMv()     + uiPart);
+  m_acCUMvField2nd[0].setMvdPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getMvd()    + uiPart);
+  m_acCUMvField2nd[0].setRefIdxPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx() + uiPart);
+  m_acCUMvField2nd[1].setMvPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getMv()     + uiPart);
+  m_acCUMvField2nd[1].setMvdPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getMvd()    + uiPart);
+  m_acCUMvField2nd[1].setRefIdxPtr(pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx() + uiPart);
+#endif
+
   m_uiSliceStartCU        = pcCU->getSliceStartCU();
   m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU();
@@ -787,4 +828,11 @@
   m_acCUMvField[eRefPicList].setMvdPtr(pcCU->getCUMvField(eRefPicList)->getMvd()    + uiAbsPartIdx);
   m_acCUMvField[eRefPicList].setRefIdxPtr(pcCU->getCUMvField(eRefPicList)->getRefIdx() + uiAbsPartIdx);
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[eRefPicList].setMvPtr(pcCU->getCUMvField2nd(eRefPicList)->getMv()     + uiAbsPartIdx);
+  m_acCUMvField2nd[eRefPicList].setMvdPtr(pcCU->getCUMvField2nd(eRefPicList)->getMvd()    + uiAbsPartIdx);
+  m_acCUMvField2nd[eRefPicList].setRefIdxPtr(pcCU->getCUMvField2nd(eRefPicList)->getRefIdx() + uiAbsPartIdx);
+#endif
+
 #if HHI_MPI
   m_piTextureModeDepth = pcCU->getTextureModeDepth() + uiAbsPartIdx;
@@ -857,4 +905,9 @@
   m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset );
   
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[0].copyFrom( pcCU->getCUMvField2nd( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset );
+  m_acCUMvField2nd[1].copyFrom( pcCU->getCUMvField2nd( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset );
+#endif
+
   UInt uiTmp  = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1);
   UInt uiTmp2 = uiPartUnitIdx*uiTmp;
@@ -943,4 +996,9 @@
   m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU );
   m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU );
+  
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[0].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU );
+  m_acCUMvField2nd[1].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU );
+#endif
   
   UInt uiTmp  = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1);
@@ -1030,4 +1088,9 @@
   m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
   m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
+  
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_acCUMvField2nd[0].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
+  m_acCUMvField2nd[1].copyTo( rpcCU->getCUMvField2nd( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart );
+#endif
   
   UInt uiTmp  = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1);
@@ -2697,4 +2760,9 @@
 #endif
   
+#if POZNAN_DBMP
+  Bool bDBMPMerge = getSlice()->getMP()->isDBMPEnabled();
+  UInt uiDBMPAddr = POZNAN_DBMP_MRG_CAND;
+#endif
+  
   bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
   for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui )
@@ -2711,5 +2779,9 @@
     pcCULeft = NULL;
   }
-  if( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) )
+  if( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    && !pcCULeft->isCUSkiped( uiLeftPartIdx )
+#endif
+  )
   {
     abCandIsInter[uiLeftAddr] = true;
@@ -2737,5 +2809,9 @@
     pcCUAbove = NULL;
   }
-  if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) )
+  if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    && !pcCUAbove->isCUSkiped( uiAbovePartIdx )
+#endif
+  )
   {
     abCandIsInter[uiAboveAddr] = true;
@@ -3183,12 +3259,63 @@
 #endif
 
+#if POZNAN_DBMP
+  //===== add point-to-point merge with depth maps =====
+  if ( bDBMPMerge )
+  {
+    //prediction of motion data for points with disocclusion:
+	UInt uiRefArrayAddr = uiDBMPAddr;
+	for(UInt ui=0; ui<MRG_MAX_NUM_CANDS; ui++) if ( ui!=uiDBMPAddr && abCandIsInter[ui] ) {uiRefArrayAddr = ui; break;}	
+	if(uiRefArrayAddr != uiDBMPAddr)
+	{
+		puhInterDirNeighbours[uiDBMPAddr] = puhInterDirNeighbours[uiRefArrayAddr];
+		pcMvFieldNeighbours[uiDBMPAddr << 1].setMvField(pcMvFieldNeighbours[uiRefArrayAddr << 1].getMv(),pcMvFieldNeighbours[uiRefArrayAddr << 1].getRefIdx());
+		pcMvFieldNeighbours[(uiDBMPAddr << 1)+1].setMvField(pcMvFieldNeighbours[(uiRefArrayAddr << 1)+1].getMv(),pcMvFieldNeighbours[(uiRefArrayAddr << 1)+1].getRefIdx());
+	}
+	else
+	{
+		TComMv cMVzero; cMVzero.setZero();
+		if( getSlice()->isInterB() ) 
+		{
+			puhInterDirNeighbours[uiDBMPAddr] = 3;
+			pcMvFieldNeighbours[uiDBMPAddr << 1].setMvField(cMVzero,0);
+			pcMvFieldNeighbours[(uiDBMPAddr << 1)+1].setMvField(cMVzero,0);
+		}
+		else 
+		{
+			if(getSlice()->getNumRefIdx(REF_PIC_LIST_0)>0) 
+			{
+				puhInterDirNeighbours[uiDBMPAddr] = 1;
+				pcMvFieldNeighbours[uiDBMPAddr << 1].setMvField(cMVzero,0);
+			}
+			else if(getSlice()->getNumRefIdx(REF_PIC_LIST_1)>0) 
+			{
+				puhInterDirNeighbours[uiDBMPAddr] = 2;
+				pcMvFieldNeighbours[(uiDBMPAddr << 1)+1].setMvField(cMVzero,0);
+			}
+			else puhInterDirNeighbours[uiDBMPAddr] = 0;
+		}
+	}	
+	if(puhInterDirNeighbours[uiDBMPAddr])
+	{		
+		abCandIsInter[uiDBMPAddr] = true;
+		puiNeighbourCandIdx[uiDBMPAddr] = uiDBMPAddr + 1;
+	}
+  }
+#endif
+
 
   //===== remove duplicates =====
   for( UInt uiOuter = 0; uiOuter < MRG_MAX_NUM_CANDS; uiOuter++ )
   {
+#if POZNAN_DBMP
+    if(uiOuter==POZNAN_DBMP_MRG_CAND) continue;
+#endif
     if( abCandIsInter[ uiOuter ] && ( puiNeighbourCandIdx[uiOuter] == uiOuter + 1 ) )
     {
       for( UInt uiIter = uiOuter + 1; uiIter < MRG_MAX_NUM_CANDS; uiIter++ )
       {
+#if POZNAN_DBMP
+        if(uiIter==POZNAN_DBMP_MRG_CAND) continue;
+#endif
         if( abCandIsInter[ uiIter ] )
         {
@@ -3271,5 +3398,9 @@
   if( uiIter == 0 )
   {
-    if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) )
+    if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+       && !pcCorner->isCUSkiped( uiCornerPUIdx )
+#endif
+    )
     {
       rbValidCand = true;
@@ -3306,5 +3437,9 @@
   else
   {
-    if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) )
+    if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+       && !pcCorner->isCUSkiped( uiCornerPUIdx )
+#endif
+    )
     {
       rbValidCand = true;
@@ -4464,4 +4599,9 @@
     return false;
   
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  if (pColCU->isSkipped(uiPartIdxCenter))
+    return false;
+#endif
+  
   if( m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getViewIdx() != m_pcSlice->getViewIdx() )
     return false;
@@ -4821,4 +4961,25 @@
   }
 #endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->copyTo( &m_acCUMvField2nd[0], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition );
+  pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->copyTo( &m_acCUMvField2nd[1], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition );
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  for( UInt ui = 0; ui < uiNumPartition; ui++ )
+  {
+    m_acCUMvField2nd[0].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[0].getMv( uiAbsPartIdxDst + ui ) >>= 2;
+
+    m_acCUMvField2nd[1].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[1].getMv( uiAbsPartIdxDst + ui ) >>= 2;
+
+    m_acCUMvField2nd[0].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[0].getMvd( uiAbsPartIdxDst + ui ) >>= 2;
+
+    m_acCUMvField2nd[1].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 );
+    m_acCUMvField2nd[1].getMvd( uiAbsPartIdxDst + ui ) >>= 2;
+  }
+#endif
+#endif
 }
 #endif
@@ -4829,2 +4990,299 @@
   riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY();  
 }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Int TComDataCU::CuQpIncrementFunction(Pel uiBlockMax)
+{
+  if((uiBlockMax >> g_uiBitIncrement) >= 256 || (uiBlockMax >> g_uiBitIncrement) <0)
+  {
+    fprintf(stderr, "Bitincrement = %d, uiBlockMax = %d\n", g_uiBitIncrement, uiBlockMax);
+    exit(333);
+  }
+  Float fVal = (Float)((255 - (uiBlockMax >> g_uiBitIncrement)) >> 4);
+  fVal = (fVal * fVal);
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+  fVal = (Float)( fVal + getPic()->getTexDqpAccordingToDepthOffset() * 32); // add offset, if offset is negative than objects in front will have smaller QP than originaly - quality in front will be increased and in bacground will be decreased
+  fVal = (Float)( fVal * getPic()->getTexDqpAccordingToDepthMul()); // 
+#else 
+  fVal = (Float)( fVal + POZNAN_TEXTURE_TU_DELTA_QP_OFFSET * 32); // add offset, if offset is negative objects in front will have smaller QP than in original approach - quality in front will be increased and in bacground will be decreased
+  fVal = (Float)( fVal * POZNAN_TEXTURE_TU_DELTA_QP_MUL); // 
+#endif
+  return (Int)fVal >> 5;
+}
+ Int  TComDataCU::getQpOffsetForTextCU(UInt uiPartIdx, Bool bIsIntra)
+ {
+   if(!getPic()->getSlice(0)->getSPS()->getUseTexDqpAccordingToDepth())
+   {
+     return 0;
+   }
+   if(this->getPic()->getSlice(0)->getSPS()->isDepth())
+   {
+     return 0;
+   }
+#if POZNAN_TEXTURE_TU_DELTA_QP_NOT_IN_BASE_VIEW
+   //if(!getPic()->getIsSideView())
+   if(this->getPic()->getViewIdx() == 0)
+   {
+     return 0;
+   }
+#endif
+   UInt iCuAddr = getAddr();
+   //TComPic * pcDepthPic = getPic()->getDepthPic();
+   TComPicYuv * pcDepthPicYUV = getPic()->getPicYuvSynthDepth();
+   if(pcDepthPicYUV /*pcDepthPic*/ == NULL)
+   {
+    char errortext[200];
+    sprintf(errortext, "depth map expected");
+    fprintf(stderr, "%s\n", errortext);
+    exit(123);
+   }
+   //TComDataCU* rpcCUDepth = pcDepthPic->getCU(iCuAddr);
+   Pel uiDepthLumaTransformBlockMax;
+   if(bIsIntra)
+   {
+     // in intra block CU each TU block has QP chosen separatly so dQP is calculated for TU
+     uiDepthLumaTransformBlockMax = getDepthLumaTransformBlockMax( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx );
+   }
+   else
+   {
+     // in inter block CU all TU block has the same QP so dQP is calculated for CU
+     uiDepthLumaTransformBlockMax = getDepthLumaCodingBlockMax( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx );
+   }
+#if POZNAN_NONLINEAR_DEPTH
+   TComNonlinearDepthBackward cNonlinearDepthBwd(getSlice()->getSPS()->getDepthPower(), g_uiBitIncrement, g_uiBitIncrement); 
+   uiDepthLumaTransformBlockMax = (Pel)( cNonlinearDepthBwd(uiDepthLumaTransformBlockMax) + 0.5);
+#endif
+   Int iDeltaQP = CuQpIncrementFunction(uiDepthLumaTransformBlockMax);
+#if POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW
+   //Int iMaxCUHeight = this->getPic()->getPicSym()->getMaxCUHeight();
+   //Int iPicHeight   = this->getPic()->getPicSym()->getPicHeight();
+   Int iMaxCUHeight = this->getPic()->getPicYuvRec()->getMaxCuHeight();
+   Int iPicHeight   = this->getPic()->getPicYuvRec()->getHeight();
+   Int iLastPelYInFirstCURow = 0 + iMaxCUHeight;
+   Int iFirstPelYInLastCURow = iPicHeight - iMaxCUHeight;
+   Int iCUStartPelY = getCUPelY();
+   if((iCUStartPelY <= iLastPelYInFirstCURow) || (iCUStartPelY >= iFirstPelYInLastCURow))
+   {
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+     iDeltaQP += getPic()->getTexDqpAccordingToDepthTopBottomRow();// POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW;
+#else
+     iDeltaQP += POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_ROW_VAL;// POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW;
+#endif
+   }
+#endif
+   return iDeltaQP;
+ }
+
+Int cmpProc(const Void *arg1, const Void *arg2)
+{
+    return *((Pel*)arg2) - *((Pel*)arg1);
+}
+
+// Function gets median value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaCodingBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int CUWidth, CUHeight;
+  sortDepthLumaCodingBlock( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, CUWidth, CUHeight );
+  return pSortTable[(CUHeight * CUWidth) / 2];
+}
+
+// Function gets maximal value of depth block that has the same size and position as texture block that calls this function
+Pel TComDataCU::getDepthLumaCodingBlockMax( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  return maxDepthLumaCodingBlock( pcDepthPicYUV /*rpcCUDepth*/, iCuAddr, uiPartIdx);  
+}
+Void TComDataCU::sortDepthLumaCodingBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& CUWidth, Int& CUHeight )
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  CUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  CUWidth  = getWidth(uiPartIdx); 
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (CUWidth >> 2) * (CUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  Int p =0;
+  Int iStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = CUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = CUWidth - 1; x >= 0; x-- )
+    {
+      pSortTable[p] = pPel[x]; ++p;
+    }
+    pPel += iStride;
+  }
+  // sort elements
+  qsort(pSortTable, CUHeight * CUWidth, sizeof(Pel), cmpProc);
+}
+
+Pel TComDataCU::maxDepthLumaCodingBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx)
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  Int CUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  Int CUWidth  = getWidth(uiPartIdx); 
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (CUWidth >> 2) * (CUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  Pel  pValue = 0;
+  Int  iStride = getPic()->getPicYuvRec()->getStride();
+  for ( y = CUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = CUWidth - 1; x >= 0; x-- )
+    {
+      if (pPel[x]>pValue) pValue = pPel[x];
+    }
+    pPel += iStride;
+  }
+  return pValue;
+}
+
+// Function gets median value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaTransformBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int TUWidth, TUHeight;
+  sortDepthLumaTransformBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, TUWidth, TUHeight );
+  return pSortTable[(TUHeight * TUWidth) / 2];
+}
+
+// Function gets maximal value of depth block that has the same size and position as texture block that calls this function
+Pel TComDataCU::getDepthLumaTransformBlockMax( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  return maxDepthLumaTransformBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx );
+}
+Void TComDataCU::sortDepthLumaTransformBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& TUWidth, Int& TUHeight )
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  TUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  TUWidth  = getWidth(uiPartIdx); 
+  // correct CU size to trnsform size:
+  if( getTransformIdx(uiPartIdx) )
+  {
+    TUWidth  = TUWidth >> 1;
+    TUHeight = TUHeight >> 1;
+  }
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (TUWidth >> 2) * (TUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  int p = 0;
+  Int  iStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = TUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = TUWidth - 1; x >= 0; x-- )
+    {
+      pSortTable[p] = pPel[x];
+    }
+    pPel += iStride;
+  }
+  // sort elements
+  qsort(pSortTable, TUHeight * TUWidth, sizeof(Pel), cmpProc);
+}
+Pel TComDataCU::maxDepthLumaTransformBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx)
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  Int TUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  Int TUWidth  = getWidth(uiPartIdx); 
+  // correct CU size to trnsform size:
+  if( getTransformIdx(uiPartIdx) )
+  {
+    TUWidth  = TUWidth >> 1;
+    TUHeight = TUHeight >> 1;
+  }
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (TUWidth >> 2) * (TUHeight >> 2);
+
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  Pel pValue = 0;
+  Int iStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = TUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = TUWidth - 1; x >= 0; x-- )
+    {
+      if (pPel[x]>pValue) pValue = pPel[x];
+    }
+    pPel += iStride;
+  }
+  return pValue;
+}
+// Function gets median value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaPredictionBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int PUWidth, PUHeight;
+  sortDepthLumaPredictionBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, PUWidth, PUHeight );
+  return pSortTable[(PUHeight * PUWidth) / 2];
+}
+
+// Function gets maximal value of depth block that has the same size and position as texture block that calls this function
+Pel  TComDataCU::getDepthLumaPredictionBlockMax( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx )
+{  
+  static Pel pSortTable [64 * 64];
+  Int PUWidth, PUHeight;
+  sortDepthLumaPredictionBlock( pcDepthPicYUV/*rpcCUDepth*/, iCuAddr, uiPartIdx, pSortTable, PUWidth, PUHeight );
+  return pSortTable[0];
+}
+Void TComDataCU::sortDepthLumaPredictionBlock ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& PUWidth, Int& PUHeight )
+{
+  Int x, y;
+  UInt uiAbsZorderIdx  = getZorderIdxInCU() + uiPartIdx;
+  // CU size: 
+  PUHeight = getHeight(uiPartIdx); // Size is based on coded texture block size not on depth picture size
+  PUWidth  = getWidth(uiPartIdx); 
+  // correct CU size to partition size:
+  if( getPartitionSize(uiPartIdx) == SIZE_Nx2N || getPartitionSize(uiPartIdx) == SIZE_NxN )
+  {
+    PUWidth = PUWidth >> 1;
+  }
+  if( getPartitionSize(uiPartIdx) == SIZE_2NxN || getPartitionSize(uiPartIdx) == SIZE_NxN )
+  {
+    PUHeight = PUHeight >> 1;
+  }
+  
+  // uiAbsZorderIdx is z order idx of one particular base block (4x4 pix) in block that we process
+  // What we need is z-order idx of first Base block (4x4 pix) in this block
+  Int iNumBase4x4InBlock = (PUWidth >> 2) * (PUHeight >> 2);
+  if(getPartitionSize(uiPartIdx) == SIZE_Nx2N)
+  {
+    iNumBase4x4InBlock = iNumBase4x4InBlock << 1; // KUBA if PU is Nx2N than to count start z-order idx we need to make such trick
+  }
+  UInt uiAbsZorderIdxBlockStart = (uiAbsZorderIdx / iNumBase4x4InBlock) * iNumBase4x4InBlock;
+  // Address of block
+  Pel* pPel   = pcDepthPicYUV/*rpcCUDepth->getPic()->getPicYuvRec()*/->getLumaAddr ( iCuAddr, uiAbsZorderIdxBlockStart );
+
+  UInt  uiStride  = getPic()->getPicYuvRec()->getStride();
+  for ( y = PUHeight - 1; y >= 0; y-- )
+  {
+    for ( x = PUWidth - 1; x >= 0; x-- )
+    {
+      pSortTable[y*PUWidth + x] = pPel[y*uiStride + x];
+    }
+  }
+  // sort elements
+  qsort(pSortTable, PUHeight * PUWidth, sizeof(Pel), cmpProc);
+}
+#endif
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDataCU.h	(revision 28)
@@ -105,4 +105,8 @@
 #endif//SNY_DQP
   
+#if POZNAN_DBMP_CALC_PRED_DATA
+  TComCUMvField m_acCUMvField2nd[2];              ///< array of motion vectors selected for points with no MP prediction available
+#endif
+  
   // -------------------------------------------------------------------------------------------------------------------
   // neighbour access variables
@@ -310,4 +314,8 @@
 #endif
   
+#if POZNAN_DBMP_CALC_PRED_DATA
+  TComCUMvField* getCUMvField2nd         ( RefPicList e )          { return  &m_acCUMvField2nd[e];  }
+#endif
+  
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for coding tool information
@@ -529,4 +537,7 @@
   Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
   Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Bool          isCUSkiped( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_SYNTH; }
+#endif
   
   // -------------------------------------------------------------------------------------------------------------------
@@ -585,4 +596,19 @@
 #endif //QC_MDCS
 
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+ Int            CuQpIncrementFunction  ( Pel uiBlockMax );
+ Int            getQpOffsetForTextCU   ( UInt uiPartIdx, Bool bIsIntra );
+ Pel            getDepthLumaCodingBlockMedian    ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaCodingBlockMax       ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Void           sortDepthLumaCodingBlock         ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx, Pel * pSortTable, Int& TUWidth, Int& TUHeight);
+ Pel            maxDepthLumaCodingBlock          ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaTransformBlockMedian ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaTransformBlockMax    ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Void           sortDepthLumaTransformBlock      ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx , Pel * pSortTable, Int& TUWidth, Int& TUHeight);
+ Pel            maxDepthLumaTransformBlock       ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaPredictionBlockMedian( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Pel            getDepthLumaPredictionBlockMax   ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx );
+ Void           sortDepthLumaPredictionBlock     ( TComPicYuv * pcDepthPicYUV/*TComDataCU* rpcCUDepth*/, UInt iCuAddr, UInt uiPartIdx , Pel * pSortTable, Int& PUWidth, Int& PUHeight);
+#endif
 };
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 28)
@@ -985,4 +985,10 @@
     xInterPredictCUDepthMap( pcSubCU, pcSubDM );
     break;
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  case MODE_SYNTH:
+    //What to do? Need Fix!
+    xIntraPredictCUDepthMap( pcSubCU, pcSubDM );
+    break;
+#endif
   default:
     AOT( true );
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComLoopFilter.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 28)
@@ -444,5 +444,9 @@
   
   //-- Set BS for Intra MB : BS = 4 or 3
-  if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ) )
+  if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+     || pcCUP->isCUSkiped(uiPartP) || pcCUQ->isCUSkiped(uiPartQ) 
+#endif
+  )
   {
     uiBs = bAtCUBoundary ? 4 : 3;   // Intra MB && MB boundary
@@ -450,5 +454,9 @@
   
   //-- Set BS for not Intra MB : BS = 2 or 1 or 0
-  if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ) )
+  if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+     && !pcCUP->isCUSkiped(uiPartP) && !pcCUQ->isCUSkiped(uiPartQ) 
+#endif
+  )
   {
     if ( pcCUQ->getCbf( uiPartQ, TEXT_LUMA, pcCUQ->getTransformIdx(uiPartQ)) != 0 || pcCUP->getCbf( uiPartP, TEXT_LUMA, pcCUP->getTransformIdx(uiPartP) ) != 0)
@@ -528,4 +536,11 @@
   }   // enf of "if( not Intra )"
   
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU //if one of the block is CUSkipped dont use loop filter
+  if ( pcCUP->isCUSkiped(uiPartP) || pcCUQ->isCUSkiped(uiPartQ))
+  {
+    uiBs = 0;
+  }
+#endif
+
   m_aapucBS[iDir][0][uiAbsPartIdx] = uiBs;
   if ( bAtCUBoundary || bAtCUHalf )
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.cpp	(revision 28)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.cpp	(revision 28)
@@ -0,0 +1,1119 @@
+
+
+#include "TComMP.h"
+//#include "../TLibSynth/TComMatrix.h"
+//#include "../TLibSynth/TSynthD2Z.h"
+//#include "../TLibSynth/TSynthZ2D.h"
+//#include "../TLibSynth/TSynthD2D.h"
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+#include "../TLibCommon/TComDepthMapGenerator.h"
+#else
+#include "../../App/TAppCommon/TAppComCamPara.h"
+#endif
+
+#if POZNAN_MP
+
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+TComMP::TComMP(UInt uiHeight, UInt uiWidth)
+#else
+//TComMP::TComMP(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData)
+TComMP::TComMP(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT)
+#endif
+{
+	m_ppiMvPtCorrX = NULL;
+	m_ppiMvPtCorrY = NULL;
+	m_ppiMvPtCorrZ = NULL;
+	m_ppiMvPtCorrRefViewIdx = NULL;
+	m_pppcRefCU = NULL;
+	m_ppuicRefPartAddr = NULL;
+
+	m_bInit = false;
+	m_bEnabled = false;
+	m_bDBMPEnabled = false;
+
+	m_uiHeight = 0;
+	m_uiWidth = 0;
+
+	m_pcRefPicsList = NULL;
+	m_pcDepthRefPicsList = NULL;
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	m_pcDepthMapGenerator = NULL;
+#else
+	//m_pcCameraData = NULL;
+	m_aiBaseViewShiftLUT = NULL;
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  m_piTempL0RefIdx = NULL;
+  m_piTempL0MvX = NULL;
+  m_piTempL0MvY = NULL;
+  m_piTempL1RefIdx = NULL;
+  m_piTempL1MvX = NULL;
+  m_piTempL1MvY = NULL;
+
+  m_piTempBuff = NULL;
+  m_piResBuff = NULL;
+#endif
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth);
+#else
+	//if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth, pcCameraData);
+	if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth, aiBaseViewShiftLUT);
+#endif
+}
+
+TComMP::~TComMP()
+{
+	uninit();
+}
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+Void TComMP::init(UInt uiHeight, UInt uiWidth)
+#else
+//Void TComMP::init(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData)
+Void TComMP::init(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT)
+#endif
+{
+	if(m_bInit) uninit();
+
+	m_bInit = true;
+	m_bEnabled = false;
+	m_bDBMPEnabled = false;
+
+	m_uiHeight = uiHeight;
+	m_uiWidth = uiWidth;
+	
+	m_pcRefPicsList = NULL;
+	m_pcDepthRefPicsList = NULL;
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	m_pcDepthMapGenerator = NULL;
+#else
+	//m_pcCameraData = pcCameraData;
+	m_aiBaseViewShiftLUT = aiBaseViewShiftLUT;
+#endif
+
+/*
+	m_ppiMvPtCorrX = new Short*[m_uiHeight];
+	m_ppiMvPtCorrY = new Short*[m_uiHeight];
+	m_ppiMvPtCorrZ = new Short*[m_uiHeight];
+	m_ppiMvPtCorrRefViewIdx = new Short*[m_uiHeight];
+	m_pppcRefCU = new TComDataCU**[m_uiHeight];
+	m_ppuicRefPartAddr = new UShort*[m_uiHeight];	
+	for(Int i=0;i<m_uiHeight;i++)
+	{
+		m_ppiMvPtCorrX[i] = new Short[m_uiWidth];
+		m_ppiMvPtCorrY[i] = new Short[m_uiWidth];
+		m_ppiMvPtCorrZ[i] = new Short[m_uiWidth];
+		m_ppiMvPtCorrRefViewIdx[i] = new Short[m_uiWidth];
+		m_pppcRefCU[i] = new TComDataCU*[m_uiWidth];
+		m_ppuicRefPartAddr[i]  = new UShort[m_uiWidth];
+	}
+//*/
+///*
+	Short* piPtr;
+	UShort* puiPtr;
+	TComDataCU** ppcPtr;
+
+	m_ppiMvPtCorrX = (Short**)malloc(sizeof(Short*)*m_uiHeight);
+	piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrX[i] = &(piPtr[addr]);
+
+	m_ppiMvPtCorrY = (Short**)malloc(sizeof(Short*)*m_uiHeight);
+	piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrY[i] = &(piPtr[addr]);
+
+	m_ppiMvPtCorrZ = (Short**)malloc(sizeof(Short*)*m_uiHeight);
+	piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrZ[i] = &(piPtr[addr]);
+
+	m_ppiMvPtCorrRefViewIdx = (Short**)malloc(sizeof(Short*)*m_uiHeight);
+	piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppiMvPtCorrRefViewIdx[i] = &(piPtr[addr]);
+
+	m_pppcRefCU = (TComDataCU***)malloc(sizeof(TComDataCU**)*m_uiHeight);
+	ppcPtr = (TComDataCU**)malloc(sizeof(TComDataCU*)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_pppcRefCU[i] = &(ppcPtr[addr]);
+
+	m_ppuicRefPartAddr = (UShort**)malloc(sizeof(UShort*)*m_uiHeight);
+	puiPtr = (UShort*)malloc(sizeof(UShort)*m_uiHeight*m_uiWidth);
+	for(UInt i=0,addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) m_ppuicRefPartAddr[i] = &(puiPtr[addr]);
+//*/
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+	m_ppiL0RefPOC.clear();
+	m_ppiL0MvX.clear();
+	m_ppiL0MvY.clear();
+	m_ppiL1RefPOC.clear();
+	m_ppiL1MvX.clear();
+	m_ppiL1MvY.clear();
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+	UInt uiSize = g_uiMaxCUHeight*g_uiMaxCUWidth;
+	m_piTempL0RefIdx = new Int[uiSize]; 
+	m_piTempL0MvX = new Int[uiSize];
+	m_piTempL0MvY = new Int[uiSize];
+	m_piTempL1RefIdx = new Int[uiSize];
+	m_piTempL1MvX = new Int[uiSize];
+	m_piTempL1MvY = new Int[uiSize];
+	m_piTempBuff = new Int[uiSize];
+	m_piResBuff = new Int[uiSize];
+#endif	
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  apcDBMPPredMVField[0] = new TComCUMvField(); apcDBMPPredMVField[0]->create(uiSize);
+  apcDBMPPredMVField[1] = new TComCUMvField(); apcDBMPPredMVField[1]->create(uiSize);
+#endif
+
+}
+
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+Void TComMP::initArrayMap(UInt uiViewId, Bool bIsDepth)
+{
+	if(bIsDepth) uiViewId += MAX_NUMBER_VIEWS;
+
+	if(m_ppiL0RefPOC.count(uiViewId)) return;
+
+	PUT_MP_ARRAY_TYPE** ppiTemp;
+	PUT_MP_ARRAY_TYPE* piTemp;
+
+/*	
+	ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth];
+	m_ppiL0RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth];
+	m_ppiL0MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth];
+	m_ppiL0MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth];
+	m_ppiL1RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth];
+	m_ppiL1MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i<m_uiHeight;i++) ppiTemp[i] = new PUT_MP_ARRAY_TYPE[m_uiWidth];
+	m_ppiL1MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+*/
+
+	ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight);
+	piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth);
+	for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]);
+	m_ppiL0RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight);
+	piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth);
+	for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]);
+	m_ppiL0MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight);
+	piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth);
+	for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]);
+	m_ppiL0MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight);
+	piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth);
+	for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]);
+	m_ppiL1RefPOC.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight);
+	piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth);
+	for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]);
+	m_ppiL1MvX.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+
+	ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight);
+	piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth);
+	for(UInt i=0, addr=0;i<m_uiHeight;i++,addr+=m_uiWidth) ppiTemp[i] = &(piTemp[addr]);
+	m_ppiL1MvY.insert(std::pair<UInt, PUT_MP_ARRAY_TYPE**>(uiViewId, ppiTemp));
+}
+#endif
+
+Void TComMP::uninit()
+{
+	if(!m_bInit) return;
+
+	m_bInit = false;
+	m_bEnabled = false;
+	m_bDBMPEnabled = false;
+	
+	m_pcRefPicsList = NULL;
+	m_pcDepthRefPicsList = NULL;
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	m_pcDepthMapGenerator = NULL;
+#else
+	//m_pcCameraData = NULL;
+	m_aiBaseViewShiftLUT = NULL;
+#endif
+
+	if(m_ppiMvPtCorrX!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrX[i];
+		//delete [] m_ppiMvPtCorrX;
+		free(m_ppiMvPtCorrX[0]);
+		free(m_ppiMvPtCorrX);
+		m_ppiMvPtCorrX = NULL;
+	}
+
+	if(m_ppiMvPtCorrY!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrY[i];
+		//delete [] m_ppiMvPtCorrY;
+		free(m_ppiMvPtCorrY[0]);
+		free(m_ppiMvPtCorrY);
+		m_ppiMvPtCorrY = NULL;
+	}
+
+	if(m_ppiMvPtCorrZ!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrZ[i];
+		//delete [] m_ppiMvPtCorrZ;
+		free(m_ppiMvPtCorrZ[0]);
+		free(m_ppiMvPtCorrZ);
+		m_ppiMvPtCorrZ = NULL;
+	}
+
+	if(m_ppiMvPtCorrRefViewIdx!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppiMvPtCorrRefViewIdx[i];
+		//delete [] m_ppiMvPtCorrRefViewIdx;
+		free(m_ppiMvPtCorrRefViewIdx[0]);
+		free(m_ppiMvPtCorrRefViewIdx);
+		m_ppiMvPtCorrRefViewIdx = NULL;
+	}
+
+	if(m_pppcRefCU!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_pppcRefCU[i];
+		//delete [] m_pppcRefCU;
+		free(m_pppcRefCU[0]);
+		free(m_pppcRefCU);
+		m_pppcRefCU = NULL;
+	}
+
+	if(m_ppuicRefPartAddr!=NULL)
+	{
+		//for(Int i=0;i<m_uiHeight;i++) delete [] m_ppuicRefPartAddr[i];
+		//delete [] m_ppuicRefPartAddr;
+		free(m_ppuicRefPartAddr[0]);
+		free(m_ppuicRefPartAddr);
+		m_ppuicRefPartAddr = NULL;
+	}
+
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+	PUT_MP_ARRAY_TYPE** ppiTemp;
+	TComMapppi::const_iterator cMapIter;
+
+    for (cMapIter = m_ppiL0RefPOC.begin(); cMapIter != m_ppiL0RefPOC.end(); cMapIter++)
+	{
+		ppiTemp = cMapIter->second;
+		if(ppiTemp!=NULL)
+		{
+			//for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i];
+			//delete [] ppiTemp;
+			free(ppiTemp[0]);
+			free(ppiTemp);
+			ppiTemp = NULL;
+		}
+	}
+	
+	for (cMapIter = m_ppiL0MvX.begin(); cMapIter != m_ppiL0MvX.end(); cMapIter++)
+	{
+		ppiTemp = cMapIter->second;
+		if(ppiTemp!=NULL)
+		{
+			//for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i];
+			//delete [] ppiTemp;
+			free(ppiTemp[0]);
+			free(ppiTemp);
+			ppiTemp = NULL;
+		}
+	}
+
+	for (cMapIter = m_ppiL0MvY.begin(); cMapIter != m_ppiL0MvY.end(); cMapIter++)
+	{
+		ppiTemp = cMapIter->second;
+		if(ppiTemp!=NULL)
+		{
+			//for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i];
+			//delete [] ppiTemp;
+			free(ppiTemp[0]);
+			free(ppiTemp);
+			ppiTemp = NULL;
+		}
+	}
+
+	for (cMapIter = m_ppiL1RefPOC.begin(); cMapIter != m_ppiL1RefPOC.end(); cMapIter++)
+	{
+		ppiTemp = cMapIter->second;
+		if(ppiTemp!=NULL)
+		{
+			//for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i];
+			//delete [] ppiTemp;
+			free(ppiTemp[0]);
+			free(ppiTemp);
+			ppiTemp = NULL;
+		}
+	}
+
+	for (cMapIter = m_ppiL1MvX.begin(); cMapIter != m_ppiL1MvX.end(); cMapIter++)
+	{
+		ppiTemp = cMapIter->second;
+		if(ppiTemp!=NULL)
+		{
+			//for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i];
+			//delete [] ppiTemp;
+			free(ppiTemp[0]);
+			free(ppiTemp);
+			ppiTemp = NULL;
+		}
+	}
+
+	for (cMapIter = m_ppiL1MvY.begin(); cMapIter != m_ppiL1MvY.end(); cMapIter++)
+	{
+		ppiTemp = cMapIter->second;
+		if(ppiTemp!=NULL)
+		{
+			//for(Int i=0;i<m_uiHeight;i++) delete [] ppiTemp[i];
+			//delete [] ppiTemp;
+			free(ppiTemp[0]);
+			free(ppiTemp);
+			ppiTemp = NULL;
+		}
+	}
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+	if(m_piTempL0RefIdx!=NULL)	{ delete [] m_piTempL0RefIdx; m_piTempL0RefIdx = NULL; }
+	if(m_piTempL0MvX!=NULL)		{ delete [] m_piTempL0MvX; m_piTempL0MvX = NULL; }
+	if(m_piTempL0MvY!=NULL)		{ delete [] m_piTempL0MvY; m_piTempL0MvY = NULL; }
+	if(m_piTempL1RefIdx!=NULL)	{ delete [] m_piTempL1RefIdx; m_piTempL1RefIdx = NULL; }
+	if(m_piTempL1MvX!=NULL)		{ delete [] m_piTempL1MvX; m_piTempL1MvX = NULL; }
+	if(m_piTempL1MvY!=NULL)		{ delete [] m_piTempL1MvY; m_piTempL1MvY = NULL; }
+	if(m_piTempBuff!=NULL)		{ delete [] m_piTempBuff; m_piTempBuff = NULL; }
+	if(m_piResBuff!=NULL)		{ delete [] m_piResBuff; m_piResBuff = NULL; }
+#endif	
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  apcDBMPPredMVField[0]->destroy(); delete apcDBMPPredMVField[0]; apcDBMPPredMVField[0] = NULL;
+  apcDBMPPredMVField[1]->destroy(); delete apcDBMPPredMVField[1]; apcDBMPPredMVField[1] = NULL;
+#endif
+
+	m_uiHeight = 0;
+	m_uiWidth = 0;
+}
+
+Void TComMP::clear()
+{
+	Int i,j;
+
+	m_bEnabled = false;
+	m_bDBMPEnabled = false;
+
+	for(i=0;i<m_uiHeight;i++)
+		for(j=0;j<m_uiWidth;j++)
+		{
+			m_ppiMvPtCorrX[i][j] = TComMP::OCCLUSION;
+			m_ppiMvPtCorrY[i][j] = TComMP::OCCLUSION;
+			//m_ppiMvPtCorrZ[i][j] = 0x7FFF; //Depth
+			m_ppiMvPtCorrZ[i][j] = TComMP::OCCLUSION; //Disparity
+			m_ppiMvPtCorrRefViewIdx[i][j] = TComMP::OCCLUSION;
+
+			m_pppcRefCU[i][j] = NULL;
+			m_ppuicRefPartAddr[i][j] = 0;
+		}
+}
+
+Void TComMP::disable()
+{
+	m_bEnabled = false;
+	m_bDBMPEnabled = false;
+
+	m_pcRefPicsList = NULL;
+	m_pcDepthRefPicsList = NULL;
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	m_pcDepthMapGenerator = NULL;
+#endif
+}
+
+Bool TComMP::isInit()
+{
+	return m_bInit;
+}
+
+Bool TComMP::isEnabled()
+{
+	return m_bEnabled;
+}
+
+Bool TComMP::isDBMPEnabled()
+{
+	return m_bDBMPEnabled;
+}
+
+Bool TComMP::pairMultiview(TComPic* pcPic)
+{
+	m_bEnabled = false;
+	m_bDBMPEnabled = false;
+
+	if(!isInit() || pcPic==NULL) return false;
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	if(m_pcDepthMapGenerator==NULL) return false;
+#else
+	//if(m_pcCameraData==NULL) return false;
+	if(m_aiBaseViewShiftLUT==NULL) return false;
+#endif
+	//if(pcPic->getSlice(0)->isIntra()) return true; //no motion compenstation is used!!!
+
+	UInt uiViewId = pcPic->getSPS()->getViewId(); //pcPic->getViewIdx();//???
+	UInt uiPOC = pcPic->getPOC();
+	Bool bIsDepth = pcPic->getSPS()->isDepth();
+
+	if(uiViewId==0) return true; //no reference view available!!!
+	
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	if(pcPic->getPredDepthMap()==NULL) return false; //no depth available!!!
+#else
+	if(m_pcDepthRefPicsList->empty()) return false; //no depth in reference views available!!!
+#endif
+
+	Int iRefX, iRefY;
+	Int iCurX, iCurY;
+	UInt uiRefViewId;	
+	TComPic* pcRefPic;
+	Int iDisparity;	
+	TComDataCU* pcRefCU;
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	Int iShiftX;
+	Int iAddX;
+#else
+	Int iSynthViewIdx;
+	Int** ppiShiftLUTLeft;
+	TComPic* pcDepthPic;
+	Int iStride;
+	Pel* pDepth;
+	//Bool bIsLeft;
+	Int  iDepth;
+#endif	
+
+	Bool bIsRefNoISliceAvailable = false;
+	Bool bIsAnchorPicture = false;
+
+	clear();
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ )
+	//for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- )
+	{
+		uiRefViewId = m_pcDepthMapGenerator->getBaseViewId( uiIdx );
+
+		iShiftX = m_pcDepthMapGenerator->getSubSampExpX() + 2;
+		iAddX = ( 1 << iShiftX ) >> 1;
+      
+		pcRefPic = (*m_pcRefPicsList)[uiRefViewId];
+
+		if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true;
+		else bIsAnchorPicture = true;
+
+		for(iCurY=0; iCurY<(Int)m_uiHeight; iCurY++)
+			for(iCurX=0; iCurX<(Int)m_uiWidth; iCurX++)
+			if((m_ppiMvPtCorrX[iCurY][iCurX]==TComMP::OCCLUSION || m_ppiMvPtCorrY[iCurY][iCurX]==TComMP::OCCLUSION))
+			{
+				iDisparity = m_pcDepthMapGenerator->getDisparity( pcPic, iCurX >> m_pcDepthMapGenerator->getSubSampExpX(), iCurY >> m_pcDepthMapGenerator->getSubSampExpY(), uiRefViewId );
+				iRefX = iCurX + ( ( iDisparity + iAddX ) >> iShiftX );
+				iRefY = iCurY;
+				
+				if(iRefX>=0 && iRefX<m_uiWidth && iRefY>=0 && iRefY<m_uiHeight)
+				{
+					//m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId;
+					m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX;
+					m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY;
+
+					Pel*   piPdmMap    = pcPic->getPredDepthMap()->getLumaAddr( 0 );
+					Int    iStride     = pcPic->getPredDepthMap()->getStride  ();
+					Int    iPrdDepth   = piPdmMap[ iCurX + iCurY * iStride ];
+					m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iPrdDepth;
+					//m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity;						
+
+					pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth()));
+
+					m_pppcRefCU[iCurY][iCurX] = pcRefCU;
+					m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()];
+				}				
+			}
+	}
+#else
+	iSynthViewIdx = uiViewId;
+
+	for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ )
+	//for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- )
+	{
+		uiRefViewId = uiIdx;
+
+		pcRefPic = GetPicFromList(m_pcRefPicsList, uiPOC, uiRefViewId);
+		assert(pcRefPic!=NULL);//test
+		if(pcRefPic==NULL) return false; //No ref pic with current POC and RefView found in ref list!!!
+
+		if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true;
+		else bIsAnchorPicture = true;
+
+		//ppiShiftLUTLeft = m_pcCameraData->getBaseViewShiftLUTI()[uiRefViewId][iSynthViewIdx];
+		ppiShiftLUTLeft = m_aiBaseViewShiftLUT[uiRefViewId][iSynthViewIdx];
+
+		pcDepthPic = GetPicFromList(m_pcDepthRefPicsList, uiPOC, uiRefViewId);
+		assert(pcDepthPic!=NULL);//test
+		if(pcDepthPic==NULL) return false; //No depth with current POC and RefView found in ref list!!!
+
+		pDepth = pcDepthPic->getPicYuvRec()->getLumaAddr();
+		iStride = pcDepthPic->getPicYuvRec()->getStride();
+
+		//bIsLeft = m_pcCameraData->isLeftView(iSynthViewIdx, uiRefViewId);
+
+		for(iRefY=0; iRefY<(Int)m_uiHeight; iRefY++)
+			for(iRefX=0; iRefX<(Int)m_uiWidth; iRefX++)
+			{				
+				iDepth = pDepth[ iRefX + iRefY * iStride ];
+				iDepth = RemoveBitIncrement(iDepth);
+				assert( iDepth >= 0 && iDepth <= 256 );					
+				
+				//if(bIsLeft) iDisparity = ppiShiftLUTLeft[0][iDepth];
+				//else iDisparity = -ppiShiftLUTLeft[0][iDepth];
+				iDisparity = ppiShiftLUTLeft[0][iDepth]; //!!!
+
+				iCurX = iRefX - ( ( iDisparity + 2 ) >> 2 );
+				iCurY = iRefY;
+				
+				if(iCurX>=0 && iCurX<m_uiWidth && iCurY>=0 && iCurY<m_uiHeight
+					&& ((m_ppiMvPtCorrX[iCurY][iCurX]==TComMP::OCCLUSION || m_ppiMvPtCorrY[iCurY][iCurX]==TComMP::OCCLUSION)
+						|| ((m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] == (Short)uiRefViewId) && (m_ppiMvPtCorrZ[iCurY][iCurX]<iDepth))))
+				{
+					m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId;
+					m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX;
+					m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY;
+
+					m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth;
+					//m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity;						
+
+					pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth()));
+
+					m_pppcRefCU[iCurY][iCurX] = pcRefCU;
+					m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()];
+				}				
+			}
+	}
+#endif
+
+#if POZNAN_MP_FILL
+	fillMultiview(uiViewId);
+#endif
+
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+	for( UInt uiIdx = 0; uiIdx <= uiViewId; uiIdx++ ) initArrayMap(uiIdx, bIsDepth);
+#endif
+	
+	m_uiView = uiViewId;
+	m_uiPOC = uiPOC;
+	m_bIsDepth = bIsDepth;
+	m_bEnabled = true;
+
+#if POZNAN_DBMP
+	m_bDBMPEnabled = (pcPic->getSPS()->getDBMP() > 0) & m_bEnabled & bIsRefNoISliceAvailable; //no reference view with motion data available
+#if POZNAN_DBMP_USE_IN_NONANCHOR_PIC_ONLY
+	m_bDBMPEnabled &= !bIsAnchorPicture; //is non-anchor picture
+#endif
+#if !POZNAN_DBMP_USE_FOR_TEXTURE
+	if(!m_bIsDepth) m_bDBMPEnabled = false;
+#endif
+#if !POZNAN_DBMP_USE_FOR_DEPTH
+	if(m_bIsDepth) m_bDBMPEnabled = false;
+#endif
+#else
+	m_bDBMPEnabled = false;
+#endif
+
+	return true;
+
+}
+
+#if POZNAN_MP_FILL
+Void TComMP::fillMultiview(UInt uiViewId)
+{
+	Int iPicXpos,iPicYpos;
+	Int iRefXpos,iRefYpos;
+	Int iRefXPos1,iRefYPos1,iRefXPos2,iRefYPos2;
+
+	for(iPicYpos=0; iPicYpos<(Int)m_uiHeight;iPicYpos++)
+		for(iPicXpos=0; iPicXpos<(Int)m_uiWidth;iPicXpos++)
+			if(m_ppiMvPtCorrX[iPicYpos][iPicXpos] == TComMP::OCCLUSION)
+			{
+				//Check left-hand  neighbours:
+				iRefXPos1=TComMP::OCCLUSION;
+				iRefYPos1=TComMP::OCCLUSION;
+
+				iRefYpos=iPicYpos;
+				for(iRefXpos=iPicXpos-1;iRefXpos>=0;iRefXpos--) 
+					if(m_ppiMvPtCorrX[iRefYpos][iRefXpos]!=TComMP::OCCLUSION)//Counterpart pixel in reference view exists
+					{
+						iRefXPos1 = iRefXpos;
+						iRefYPos1 = iRefYpos;
+						break;
+					}
+
+				//Check right-hand  neighbours:
+				iRefXPos2=TComMP::OCCLUSION;
+				iRefYPos2=TComMP::OCCLUSION;
+
+				iRefYpos=iPicYpos;
+				for(iRefXpos=iPicXpos+1;iRefXpos<m_uiWidth;iRefXpos++) 
+					if(m_ppiMvPtCorrX[iRefYpos][iRefXpos]!=TComMP::OCCLUSION)//Counterpart pixel in reference view exists
+					{
+						iRefXPos2 = iRefXpos;
+						iRefYPos2 = iRefYpos;
+						break;
+					}
+
+#if POZNAN_MP_FILL_TYPE==0
+
+				//Choose point with smaller disparity:
+				if(iRefXPos1!=TComMP::OCCLUSION && iRefYPos1!=TComMP::OCCLUSION)
+				{
+					if(iRefXPos2!=TComMP::OCCLUSION && iRefYPos2!=TComMP::OCCLUSION && m_ppiMvPtCorrZ[iRefYPos1][iRefXPos1]>m_ppiMvPtCorrZ[iRefYPos2][iRefXPos2])
+					{
+						iRefXpos=iRefXPos2;
+						iRefYpos=iRefYPos2;
+					}
+					else
+					{
+						iRefXpos=iRefXPos1;
+						iRefYpos=iRefYPos1;
+					}
+				}
+				else
+				{
+					iRefXpos=iRefXPos2;
+					iRefYpos=iRefYPos2;
+				}
+				if(iRefXpos==TComMP::OCCLUSION && iRefYpos==TComMP::OCCLUSION) continue;
+
+#elif POZNAN_MP_FILL_TYPE==1
+
+				//Choose point with larger disparity:
+				if(iRefXPos1!=TComMP::OCCLUSION && iRefYPos1!=TComMP::OCCLUSION)
+				{
+					if(iRefXPos2!=TComMP::OCCLUSION && iRefYPos2!=TComMP::OCCLUSION && m_ppiMvPtCorrZ[iRefYPos1][iRefXPos1]<m_ppiMvPtCorrZ[iRefYPos2][iRefXPos2])
+					{
+						iRefXpos=iRefXPos2;
+						iRefYpos=iRefYPos2;
+					}
+					else
+					{
+						iRefXpos=iRefXPos1;
+						iRefYpos=iRefYPos1;
+					}
+				}
+				else
+				{
+					iRefXpos=iRefXPos2;
+					iRefYpos=iRefYPos2;
+				}
+				if(iRefXpos==TComMP::OCCLUSION && iRefYpos==TComMP::OCCLUSION) continue;
+
+#else
+				assert(0);
+#endif
+				
+				//m_ppiMvPtCorrRefViewIdx[iPicYpos][iPicXpos] = m_ppiMvPtCorrRefViewIdx[iRefYpos][iRefXpos];
+				m_ppiMvPtCorrX[iPicYpos][iPicXpos] = m_ppiMvPtCorrX[iRefYpos][iRefXpos]; //m_ppiMvPtCorrX[iPicYpos][iPicXpos] = iRefXpos;
+				m_ppiMvPtCorrY[iPicYpos][iPicXpos] = m_ppiMvPtCorrY[iRefYpos][iRefXpos]; //m_ppiMvPtCorrY[iPicYpos][iPicXpos] = iRefYpos;
+				
+				//m_ppiMvPtCorrZ[iPicYpos][iPicXpos] = m_ppiMvPtCorrZ[iRefYpos][iRefXpos];
+				m_pppcRefCU[iPicYpos][iPicXpos] = m_pppcRefCU[iRefYpos][iRefXpos];
+				m_ppuicRefPartAddr[iPicYpos][iPicXpos] = m_ppuicRefPartAddr[iRefYpos][iRefXpos];
+			}
+
+	return;
+}
+#endif
+
+TComPic* TComMP::GetPicFromList(std::vector<TComPic*>* pcListPic,UInt uiPOC, UInt uiView) //Get Pic from list based on POC ad View
+{
+  //  find current position
+  std::vector<TComPic*>::iterator  iterPic;
+  TComPic*                      pcPic   = NULL;
+  
+  for(iterPic = pcListPic->begin(); iterPic != pcListPic->end(); iterPic++)
+  {
+	pcPic = *(iterPic);
+	if((pcPic->getPOC() == (Int)uiPOC) && (pcPic->getViewIdx() == (Int)uiView) && pcPic->getReconMark()) return pcPic;
+	//if((pcPic->getPOC() == (Int)uiPOC) && (pcPic->getViewIdx() == (Int)uiView) ) return pcPic;
+  }
+  assert (0);
+
+  return NULL;
+}
+
+Int TComMP::GetRepresentativeVal(UInt &uiCntMax, Int* piIn, UInt uiLen, Int* piTemp, Bool bUseRestrictedVal, Int iRestrictedVal)
+{
+	UInt i,j,cnt,idx;
+
+	uiCntMax = 0; idx = -1;
+	for(i=0;i<uiLen;i++) piTemp[i] = 0;
+	for(i=0;i<uiLen;i++)
+	{
+		if(piTemp[i] || (bUseRestrictedVal && piIn[i]==iRestrictedVal)) continue;
+		cnt = 0; for(j=0;j<uiLen;j++) if(piIn[j]==piIn[i]) {cnt++; piTemp[j] = 1;}
+		if(cnt>uiCntMax || (cnt==uiCntMax && abs(piIn[i])<abs(piIn[idx]))) {uiCntMax = cnt; idx = i;}		
+	}
+
+	if(idx==-1) return iRestrictedVal;
+	return piIn[idx];
+}
+
+#if POZNAN_DBMP
+inline Void TComMP::getDBMPPredData(TComDataCU* pcCU, Int x, Int y, 
+											Int &ref_frame0, Int &ref_frame0_idx, TComMv &mv0, Int ref_frame0_idx_2nd, TComMv mv0_2nd,
+											Int &ref_frame1, Int &ref_frame1_idx, TComMv &mv1, Int ref_frame1_idx_2nd, TComMv mv1_2nd)
+{
+	UInt uiViewId = pcCU->getSlice()->getSPS()->getViewId();
+	Bool bIsDepth = pcCU->getSlice()->getSPS()->isDepth();
+	Int iRefIdx;
+	TComPic* pcPic;
+	TComMP* pcMP = pcCU->getSlice()->getMP();
+
+	TComDataCU*pcRefCU = pcMP->getMPCRefCU()[y][x];
+	UInt uiRefPartAddr = pcMP->getMPCRefPartAddr()[y][x];
+
+	Int x_ref = pcMP->getMPCx()[y][x];
+	Int y_ref = pcMP->getMPCy()[y][x];
+
+	ref_frame0 = -1;
+	ref_frame1 = -1;			
+
+	if(pcRefCU != NULL) //Point has its counterpart in the reference view		
+	{			
+#if !POZNAN_DBMP_COMPRESS_ME_DATA
+		if(pcRefCU->getMergeIndex(uiRefPartAddr)==POZNAN_DBMP_MRG_CAND)
+		{
+			UInt uiRefViewId = pcRefCU->getSlice()->getSPS()->getViewId();
+
+			ref_frame0 = pcMP->getL0RefPOC(uiRefViewId, bIsDepth)[y_ref][x_ref];
+			mv0.setHor(pcMP->getL0MvX(uiRefViewId, bIsDepth)[y_ref][x_ref]);
+			mv0.setVer(pcMP->getL0MvY(uiRefViewId, bIsDepth)[y_ref][x_ref]);
+			
+			ref_frame1 = pcMP->getL1RefPOC(uiRefViewId, bIsDepth)[y_ref][x_ref];
+			mv1.setHor(pcMP->getL1MvX(uiRefViewId, bIsDepth)[y_ref][x_ref]);
+			mv1.setVer(pcMP->getL1MvY(uiRefViewId, bIsDepth)[y_ref][x_ref]);
+		}
+		else
+		{
+#endif
+			if(pcRefCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiRefPartAddr)>=0)
+			{
+				ref_frame0 = pcRefCU->getSlice()->getRefPOC( REF_PIC_LIST_0, pcRefCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiRefPartAddr) );
+				mv0 = pcRefCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiRefPartAddr );
+			}
+
+			if(pcRefCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiRefPartAddr)>=0)
+			{
+				ref_frame1 = pcRefCU->getSlice()->getRefPOC( REF_PIC_LIST_1, pcRefCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiRefPartAddr) );
+				mv1 = pcRefCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiRefPartAddr );
+			}
+#if !POZNAN_DBMP_COMPRESS_ME_DATA
+		}
+#endif
+	}
+
+	//Find ref_frame0 index on REF_PIC_LIST_0
+	ref_frame0_idx = -1;
+	if(ref_frame0 != -1)
+	{				
+		for( iRefIdx = 0; iRefIdx < pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0); iRefIdx++ )
+		{
+			pcPic = pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, iRefIdx );
+			if(ref_frame0 == pcPic->getPOC() && uiViewId==pcPic->getSPS()->getViewId()){ ref_frame0_idx = iRefIdx; break;}
+		}
+		if(ref_frame0_idx == -1) ref_frame0 = -1;
+	}
+	//Find ref_frame1 index on REF_PIC_LIST_1
+	ref_frame1_idx = -1;
+	if(ref_frame1 != -1)
+	{				
+		for( iRefIdx = 0; iRefIdx < pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1); iRefIdx++ )
+		{
+			pcPic = pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, iRefIdx );
+			if(ref_frame1 == pcPic->getPOC() && uiViewId==pcCU->getSlice()->getSPS()->getViewId()){ ref_frame1_idx = iRefIdx; break;}
+		}
+		if(ref_frame1_idx == -1) ref_frame1 = -1;
+	}
+
+	if(ref_frame0_idx < 0 && ref_frame1_idx < 0) //No counterpart pixel in reference view found or no motion data was found
+	{
+		ref_frame0_idx = ref_frame0_idx_2nd;
+		mv0 = mv0_2nd;
+		if(ref_frame0_idx_2nd == -1) ref_frame0 = -1;
+		else ref_frame0 = pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, ref_frame0_idx_2nd )->getPOC();
+
+		ref_frame1_idx = ref_frame1_idx_2nd;
+		mv1 = mv1_2nd;
+		if(ref_frame1_idx_2nd == -1) ref_frame1 = -1;
+		else ref_frame1 = pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, ref_frame1_idx_2nd )->getPOC();
+	}
+	else //Counterpart point with motion data was found
+	{
+		if(ref_frame0_idx < 0) 
+		{
+			ref_frame0_idx = -1;
+			mv0.setZero();
+		}
+		else
+		{
+			//use mv0 and RefIdx obtained by the DBMP algorithm
+		}
+
+		if(ref_frame1_idx < 0) 
+		{
+			ref_frame1_idx = -1;
+			mv1.setZero();
+		}
+		else
+		{
+			//use mv0 and RefIdx obtained by the DBMP algorithm
+		}
+	}
+}
+
+#if !POZNAN_DBMP_COMPRESS_ME_DATA
+Void TComMP::saveDBMPData(TComDataCU* pcCU)
+{	
+	if(!isDBMPEnabled()) return;
+
+	Int		  px,py,x,y,iCUBaseX,iCUBaseY;
+
+	Int		  ref_frame0, ref_frame1;
+	Int		  ref_frame0_idx, ref_frame1_idx;
+	TComMv	  mv0,mv1;
+
+	Int		  ref_frame0_idx_2nd, ref_frame1_idx_2nd;
+    TComMv	  mv0_2nd,mv1_2nd;
+
+	UInt	  uiViewId = pcCU->getSlice()->getSPS()->getViewId();
+	Bool	  bIsDepth = pcCU->getSlice()->getSPS()->isDepth();
+	Int		  iWidth = g_uiMaxCUWidth>>g_uiMaxCUDepth;
+	Int		  iHeight = g_uiMaxCUHeight>>g_uiMaxCUDepth;
+
+	for (UInt uiPartAddr = 0; uiPartAddr < pcCU->getTotalNumPart(); uiPartAddr++ )
+	{
+		if(pcCU->getMergeIndex(uiPartAddr)==POZNAN_DBMP_MRG_CAND)
+		{			
+#if POZNAN_DBMP_CALC_PRED_DATA
+			ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+			mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+
+			ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
+			mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+#else
+			ref_frame0_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+			mv0_2nd = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+
+			ref_frame1_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
+			mv1_2nd = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+#endif
+			iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiPartAddr] ];
+			iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiPartAddr] ];
+			for( py = 0; py < iHeight; py++)
+			{
+				y = iCUBaseY+py;
+				for( px = 0; px < iWidth; px++)
+				{
+					x = iCUBaseX+px;
+
+					getDBMPPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, 
+										ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd);
+
+					setL0RefPOC(uiViewId,bIsDepth,x,y,ref_frame0);
+					setL0MvX(uiViewId,bIsDepth,x,y,mv0.getHor());
+					setL0MvY(uiViewId,bIsDepth,x,y,mv0.getVer());
+
+					setL1RefPOC(uiViewId,bIsDepth,x,y,ref_frame1);
+					setL1MvX(uiViewId,bIsDepth,x,y,mv1.getHor());
+					setL1MvY(uiViewId,bIsDepth,x,y,mv1.getVer());
+				}
+			}
+		}
+	}
+}
+#endif
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+Void TComMP::calcDBMPPredData(TComDataCU* pcCU, UInt uiAbsPartIdx, Int &ref_frame0_idx,  TComMv &mv0, Int &ref_frame1_idx,  TComMv &mv1)
+{	
+	if(!isDBMPEnabled() || pcCU->getMergeIndex(uiAbsPartIdx)!=POZNAN_DBMP_MRG_CAND) return;
+
+	Int iWidth,iHeight;
+	Int x,y,iCUBaseX,iCUBaseY;
+
+	switch(pcCU->getPartitionSize( uiAbsPartIdx ))
+	{
+		case SIZE_2Nx2N:
+			iWidth = pcCU->getWidth(uiAbsPartIdx);
+			iHeight = pcCU->getHeight(uiAbsPartIdx);			
+			break;
+		case SIZE_2NxN:
+			iWidth = pcCU->getWidth(uiAbsPartIdx);
+			iHeight = pcCU->getHeight(uiAbsPartIdx) >> 1;
+			break;
+		case SIZE_Nx2N:
+			iWidth = pcCU->getWidth(uiAbsPartIdx) >> 1;
+			iHeight = pcCU->getHeight(uiAbsPartIdx);
+			break;
+		case SIZE_NxN:
+			iWidth = pcCU->getWidth(uiAbsPartIdx) >> 1;
+			iHeight = pcCU->getHeight(uiAbsPartIdx) >> 1;
+			break;
+		default: assert(0);
+	}	
+
+	Int	ref_frame0, ref_frame1;
+		
+	Int ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx);
+	TComMv mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiAbsPartIdx );
+
+	Int ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx);
+	TComMv mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiAbsPartIdx );
+
+	iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
+	iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
+
+	UInt	  uiPointCnt = 0;
+			
+	for( y = iCUBaseY; y < iCUBaseY+iHeight; y++)
+		for( x = iCUBaseX; x < iCUBaseX+iWidth; x++)
+		{
+			getDBMPPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, 
+								ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd);
+
+			m_piTempL0RefIdx[uiPointCnt] = ref_frame0_idx;
+			m_piTempL0MvX[uiPointCnt] = mv0.getHor();
+			m_piTempL0MvY[uiPointCnt] = mv0.getVer();
+
+			m_piTempL1RefIdx[uiPointCnt] = ref_frame1_idx;
+			m_piTempL1MvX[uiPointCnt] = mv1.getHor();
+			m_piTempL1MvY[uiPointCnt] = mv1.getVer();			
+	
+			uiPointCnt++;
+		}
+
+	xCalcDBMPPredData(uiPointCnt, ref_frame0_idx, mv0, ref_frame1_idx, mv1);
+}
+
+Void TComMP::setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU)
+{
+	apcDBMPPredMVField[eRefListIdx]->copyFrom(pcCU->getCUMvField(eRefListIdx), pcCU->getTotalNumPart(), 0);
+}
+
+Void TComMP::setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU, Int iNumPartSrc, Int iPartAddrDst)
+{
+	apcDBMPPredMVField[eRefListIdx]->copyFrom(pcCU->getCUMvField(eRefListIdx), iNumPartSrc, iPartAddrDst);
+}
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+inline Void TComMP::xCalcDBMPPredData(UInt uiCnt, Int &ref_frame0_idx, TComMv &mv0, Int &ref_frame1_idx, TComMv &mv1)
+{	
+	if(uiCnt==0) return;
+
+	Int iVal;
+	UInt i,uiCntMax,uiCntTemp;
+
+	//for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL0RefIdx[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff);	ref_frame0_idx = iVal;
+	//for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL0MvX[i];	  iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff);	mv0.setHor(iVal);
+	//for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL0MvY[i];	  iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff);	mv0.setVer(iVal);
+	//for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL1RefIdx[i]; iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff);	ref_frame1_idx = iVal;
+	//for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL1MvX[i];	  iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff);	mv1.setHor(iVal);
+	//for(i=0;i<uiCnt;i++) m_piResBuff[i] = (Int)m_piTempL1MvY[i];	  iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCnt, m_piTempBuff);	mv1.setVer(iVal);
+	
+	//iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff);	ref_frame0_idx = iVal;
+	//iVal = GetRepresentativeVal(uiCntMax, m_piTempL0MvX, uiCnt, m_piTempBuff);		mv0.setHor(iVal);
+	//iVal = GetRepresentativeVal(uiCntMax, m_piTempL0MvY, uiCnt, m_piTempBuff);		mv0.setVer(iVal);
+	//iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff);	ref_frame1_idx = iVal;
+	//iVal = GetRepresentativeVal(uiCntMax, m_piTempL1MvX, uiCnt, m_piTempBuff);		mv1.setHor(iVal);
+	//iVal = GetRepresentativeVal(uiCntMax, m_piTempL1MvY, uiCnt, m_piTempBuff);		mv1.setVer(iVal);
+
+	iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff);	ref_frame0_idx = iVal;
+	//if(ref_frame0_idx==-1 && (uiCntMax<<1)==uiCnt) 
+	//{
+	//	iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, -1);	
+	//	if((uiCntMax<<1)==uiCnt) ref_frame0_idx = iVal;
+	//}
+	//if((uiCntMax<<1)==uiCnt) 
+	//{
+	//	iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, ref_frame0_idx);	
+	//	if((uiCntMax<<1)==uiCnt && (ref_frame0_idx==-1 || (iVal!=-1 && iVal<ref_frame0_idx))) ref_frame0_idx = iVal;
+	//}
+	if((uiCntMax<<1)<=uiCnt)
+	{
+		iVal = GetRepresentativeVal(uiCntTemp, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, ref_frame0_idx);
+		if(uiCntTemp==uiCntMax && (ref_frame0_idx==-1 || (iVal!=-1 && iVal<ref_frame0_idx))) ref_frame0_idx = iVal;
+	}
+
+	iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff);	ref_frame1_idx = iVal;
+	//if(ref_frame1_idx==-1 && (uiCntMax<<1)==uiCnt) 
+	//{
+	//	iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, -1);	
+	//	if((uiCntMax<<1)==uiCnt) ref_frame1_idx = iVal;
+	//}
+	//if((uiCntMax<<1)==uiCnt) 
+	//{
+	//	iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, ref_frame1_idx);	
+	//	if((uiCntMax<<1)==uiCnt && (ref_frame1_idx==-1 || (iVal!=-1 && iVal<ref_frame1_idx))) ref_frame1_idx = iVal;
+	//}
+	if((uiCntMax<<1)<=uiCnt)
+	{
+		iVal = GetRepresentativeVal(uiCntTemp, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, ref_frame1_idx);
+		if(uiCntTemp==uiCntMax && (ref_frame1_idx==-1 || (iVal!=-1 && iVal<ref_frame1_idx))) ref_frame1_idx = iVal;
+	}
+
+	if(ref_frame0_idx==-1 && ref_frame1_idx==-1)
+	{
+		iVal = GetRepresentativeVal(uiCntMax, m_piTempL0RefIdx, uiCnt, m_piTempBuff, true, -1);	ref_frame0_idx = iVal;
+		iVal = GetRepresentativeVal(uiCntMax, m_piTempL1RefIdx, uiCnt, m_piTempBuff, true, -1);	ref_frame1_idx = iVal;
+	}
+
+	if(ref_frame0_idx==-1) 
+	{
+		mv0.setHor(0);
+		mv0.setVer(0);
+	}
+	else
+	{
+		uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL0RefIdx[i]==ref_frame0_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL0MvX[i]; 
+		iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff);	mv0.setHor(iVal);
+
+		uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL0RefIdx[i]==ref_frame0_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL0MvY[i];
+		iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff);	mv0.setVer(iVal);
+	}	
+	
+	if(ref_frame1_idx==-1) 
+	{
+		mv1.setHor(0);
+		mv1.setVer(0);
+	}
+	else
+	{
+		uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL1RefIdx[i]==ref_frame1_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL1MvX[i];	 
+		iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff);	mv1.setHor(iVal);
+
+		uiCntTemp=0; for(i=0;i<uiCnt;i++) if(m_piTempL1RefIdx[i]==ref_frame1_idx) m_piResBuff[uiCntTemp++] = (Int)m_piTempL1MvY[i];	 
+		iVal = GetRepresentativeVal(uiCntMax, m_piResBuff, uiCntTemp, m_piTempBuff);	mv1.setVer(iVal);
+	}
+}
+#endif
+
+
+
+
+#endif	// POZNAN_MP
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.h	(revision 28)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComMP.h	(revision 28)
@@ -0,0 +1,201 @@
+
+
+#ifndef __TCOMMP__
+#define __TCOMMP__
+
+class TComMP;
+
+#include "../TLibCommon/TypeDef.h"
+#include "../TLibCommon/CommonDef.h"
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+class TComDepthMapGenerator;
+//#include "../TLibCommon/TComDepthMapGenerator.h"
+#else
+class TAppComCamPara;
+//#include "../../App/TAppCommon/TAppComCamPara.h"
+#endif
+
+#include "../TLibCommon/TComList.h"
+#include "../TLibCommon/TComSlice.h"
+#include "../TLibCommon/TComPic.h"
+#include "../TLibCommon/TComDataCU.h"
+#include "../TLibCommon/TComMotionInfo.h"
+
+#include <map>
+//#include <cstdlib>
+//using namespace std;
+
+#if POZNAN_MP
+
+// ====================================================================================================================
+// Class definition
+// ====================================================================================================================
+
+
+/// MP class
+class TComMP
+{
+//typedef Int PUT_MP_ARRAY_TYPE;
+typedef Short PUT_MP_ARRAY_TYPE;
+typedef std::map<UInt,PUT_MP_ARRAY_TYPE**> TComMapppi;
+
+static const int OCCLUSION = -1;
+
+private:
+
+  Bool m_bInit;
+  Bool m_bEnabled;
+  Bool m_bDBMPEnabled;
+
+  UInt m_uiHeight;
+  UInt m_uiWidth;
+
+  UInt m_uiPOC;
+  UInt m_uiView;
+  Bool m_bIsDepth;
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  TComDepthMapGenerator* m_pcDepthMapGenerator;
+#else
+  //TAppComCamPara* m_pcCameraData;
+  Int**** m_aiBaseViewShiftLUT;
+#endif
+  std::vector<TComPic*>* m_pcRefPicsList;
+  std::vector<TComPic*>* m_pcDepthRefPicsList;
+
+  Short** m_ppiMvPtCorrX;
+  Short** m_ppiMvPtCorrY;
+  Short** m_ppiMvPtCorrZ;
+  Short** m_ppiMvPtCorrRefViewIdx;
+
+  TComDataCU*** m_pppcRefCU; //XY array of pointers to reference CU for each point of picture
+  UShort** m_ppuicRefPartAddr; //XY array of part addresses for each reference CU for each point of picture
+
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+  TComMapppi m_ppiL0RefPOC;
+  TComMapppi m_ppiL0MvX;
+  TComMapppi m_ppiL0MvY;
+  TComMapppi m_ppiL1RefPOC;
+  TComMapppi m_ppiL1MvX;
+  TComMapppi m_ppiL1MvY;
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  Int* m_piTempL0RefIdx;
+  Int* m_piTempL0MvX;
+  Int* m_piTempL0MvY;
+  Int* m_piTempL1RefIdx;
+  Int* m_piTempL1MvX;
+  Int* m_piTempL1MvY;
+
+  Int*	m_piTempBuff;
+  Int*	m_piResBuff;
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  TComCUMvField* apcDBMPPredMVField[2];
+#endif
+
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+  Void initArrayMap(UInt uiViewId, Bool bIsDepth);
+#endif
+
+public:
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  TComMP(UInt uiHeight=0, UInt uiWidth=0);
+#else
+  //TComMP(UInt uiHeight=0, UInt uiWidth=0, TAppComCamPara* pcCameraData=NULL);
+  TComMP(UInt uiHeight=0, UInt uiWidth=0, Int**** aiBaseViewShiftLUT=NULL);
+#endif
+  ~TComMP();
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  Void			init(UInt uiHeight, UInt uiWidth);
+#else
+  //Void			init(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData);
+  Void			init(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT);
+#endif
+  Void			uninit();
+  Void			clear();
+  Void			disable();
+
+  Bool			isInit();
+  Bool			isEnabled();
+  Bool			isDBMPEnabled();
+
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+  Void			setDepthMapGenerator(TComDepthMapGenerator*  pcDepthMapGenerator){m_pcDepthMapGenerator = pcDepthMapGenerator;}
+#endif  
+  Void			setRefPicsList(std::vector<TComPic*>* pcListPic){m_pcRefPicsList = pcListPic;}
+  Void			setDepthRefPicsList(std::vector<TComPic*>* pcListPic){m_pcDepthRefPicsList = pcListPic;}
+  Bool			pairMultiview(TComPic* pcPic);
+
+  Short**		getMPCx() {return m_ppiMvPtCorrX;}
+  Short**		getMPCy() {return m_ppiMvPtCorrY;}
+  Short**		getMPCz() {return m_ppiMvPtCorrZ;}
+  Short**		getMPCRefViewIdx() {return m_ppiMvPtCorrRefViewIdx;}
+  TComDataCU***	getMPCRefCU() {return m_pppcRefCU;}
+  UShort**		getMPCRefPartAddr() {return m_ppuicRefPartAddr;}
+
+#if POZNAN_MP_FILL
+  Void			fillMultiview(UInt uiViewId);
+#endif
+
+#if POZNAN_DBMP
+#if !POZNAN_DBMP_COMPRESS_ME_DATA
+  PUT_MP_ARRAY_TYPE**			getL0RefPOC(UInt uiViewID, Bool bIsDepth) {return m_ppiL0RefPOC[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID];}
+  PUT_MP_ARRAY_TYPE**			getL0MvX(UInt uiViewID, Bool bIsDepth) {return m_ppiL0MvX[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID];}
+  PUT_MP_ARRAY_TYPE**			getL0MvY(UInt uiViewID, Bool bIsDepth) {return m_ppiL0MvY[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID];}
+  PUT_MP_ARRAY_TYPE**			getL1RefPOC(UInt uiViewID, Bool bIsDepth) {return m_ppiL1RefPOC[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID];}
+  PUT_MP_ARRAY_TYPE**			getL1MvX(UInt uiViewID, Bool bIsDepth) {return m_ppiL1MvX[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID];}
+  PUT_MP_ARRAY_TYPE**			getL1MvY(UInt uiViewID, Bool bIsDepth) {return m_ppiL1MvY[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID];}
+
+  Void			setL0RefPOC(UInt uiViewID, Bool bIsDepth, UInt uiX, UInt uiY, PUT_MP_ARRAY_TYPE iVal) {m_ppiL0RefPOC[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID][uiY][uiX]=iVal;}
+  Void			setL0MvX(UInt uiViewID, Bool bIsDepth, UInt uiX, UInt uiY, PUT_MP_ARRAY_TYPE iVal) {m_ppiL0MvX[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID][uiY][uiX]=iVal;}
+  Void			setL0MvY(UInt uiViewID, Bool bIsDepth, UInt uiX, UInt uiY, PUT_MP_ARRAY_TYPE iVal) {m_ppiL0MvY[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID][uiY][uiX]=iVal;}
+  Void			setL1RefPOC(UInt uiViewID, Bool bIsDepth, UInt uiX, UInt uiY, PUT_MP_ARRAY_TYPE iVal) {m_ppiL1RefPOC[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID][uiY][uiX]=iVal;}
+  Void			setL1MvX(UInt uiViewID, Bool bIsDepth, UInt uiX, UInt uiY, PUT_MP_ARRAY_TYPE iVal) {m_ppiL1MvX[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID][uiY][uiX]=iVal;}
+  Void			setL1MvY(UInt uiViewID, Bool bIsDepth, UInt uiX, UInt uiY, PUT_MP_ARRAY_TYPE iVal) {m_ppiL1MvY[(bIsDepth)? (uiViewID+MAX_NUMBER_VIEWS) : uiViewID][uiY][uiX]=iVal;}
+
+  Void saveDBMPData(TComDataCU* pcCU);
+#endif
+
+  inline Void getDBMPPredData(TComDataCU* pcCU, Int x, Int y, 
+							  Int &ref_frame0, Int &ref_frame0_idx, TComMv &mv0, Int ref_frame0_idx_2nd, TComMv mv0_2nd,
+							  Int &ref_frame1, Int &ref_frame1_idx, TComMv &mv1, Int ref_frame1_idx_2nd, TComMv mv1_2nd);
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  Int*			getTempL0RefIdx() {return m_piTempL0RefIdx;}
+  Int*			getTempL0MvX() {return m_piTempL0MvX;}
+  Int*			getTempL0MvY() {return m_piTempL0MvY;}
+  Int*			getTempL1RefIdx() {return m_piTempL1RefIdx;}
+  Int*			getTempL1MvX() {return m_piTempL1MvX;}
+  Int*			getTempL1MvY() {return m_piTempL1MvY;}
+  
+  inline Void xCalcDBMPPredData(UInt uiCnt, Int &ref_frame0_idx, TComMv &mv0, Int &ref_frame1_idx, TComMv &mv1);
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  Void calcDBMPPredData(TComDataCU* pcCU, UInt uiAbsPartIdx, Int &ref_frame0_idx,  TComMv &mv0, Int &ref_frame1_idx,  TComMv &mv1);
+  TComCUMvField* getDBMPPredMVField(RefPicList eRefListIdx){return apcDBMPPredMVField[eRefListIdx];}
+  Void setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU);
+  Void setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU, Int iNumPartSrc, Int iPartAddrDst);
+#endif
+
+  TComPic*		GetPicFromList(std::vector<TComPic*>* rcListPic, UInt uiPOC, UInt uiView);
+  Int			GetRepresentativeVal(UInt &uiCntMax, Int* puiIn, UInt uiLen, Int* puiTemp, Bool bUseRestrictedVal=false, Int uiRestrictedVal=0);
+
+};
+
+
+
+
+//#endif
+
+#endif // __TCOMMP__
+
+
+#endif // POZNAN_MP
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPic.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPic.cpp	(revision 28)
@@ -50,4 +50,13 @@
   m_apcPicYuv[0]      = NULL;
   m_apcPicYuv[1]      = NULL;
+#if POZNAN_AVAIL_MAP
+  m_apcPicYuvAvail     = NULL;
+#endif
+#if POZNAN_SYNTH_VIEW
+  m_apcPicYuvSynth     = NULL;
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_apcPicYuvSynthDepth= NULL; 
+#endif
 #if DEPTH_MAP_GENERATION
   m_pcPredDepthMap    = NULL;
@@ -118,4 +127,29 @@
     m_apcPicYuv[1]  = NULL;
   }
+#if POZNAN_AVAIL_MAP
+  if (m_apcPicYuvAvail)
+  {
+    m_apcPicYuvAvail->destroy();
+    delete m_apcPicYuvAvail;
+    m_apcPicYuvAvail  = NULL;
+  }
+#endif
+
+#if POZNAN_SYNTH_VIEW
+  if (m_apcPicYuvSynth)
+  {
+    m_apcPicYuvSynth->destroy();
+    delete m_apcPicYuvSynth;
+    m_apcPicYuvSynth  = NULL;
+  }
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  if (m_apcPicYuvSynthDepth)
+  {
+    m_apcPicYuvSynthDepth->destroy();
+    delete m_apcPicYuvSynthDepth;
+    m_apcPicYuvSynthDepth  = NULL;
+  }
+#endif
   
 #if DEPTH_MAP_GENERATION
@@ -195,4 +229,52 @@
 }
 
+#if POZNAN_AVAIL_MAP
+Void
+TComPic::addAvailabilityBuffer()
+{
+  AOT( m_apcPicYuvAvail );
+  AOF( m_apcPicYuv[1] );
+  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
+  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
+  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
+  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
+  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
+  m_apcPicYuvAvail      = new TComPicYuv;
+  m_apcPicYuvAvail      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
+}
+#endif
+
+#if POZNAN_SYNTH_VIEW
+Void
+TComPic::addSynthesisBuffer()
+{
+  AOT( m_apcPicYuvSynth );
+  AOF( m_apcPicYuv[1] );
+  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
+  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
+  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
+  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
+  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
+  m_apcPicYuvSynth      = new TComPicYuv;
+  m_apcPicYuvSynth      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
+}
+#endif
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Void
+TComPic::addSynthesisDepthBuffer()
+{
+  AOT( m_apcPicYuvSynthDepth );
+  AOF( m_apcPicYuv[1] );
+  Int   iWidth        = m_apcPicYuv[1]->getWidth      ();
+  Int   iHeight       = m_apcPicYuv[1]->getHeight     ();
+  UInt  uiMaxCuWidth  = m_apcPicYuv[1]->getMaxCuWidth ();
+  UInt  uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight();
+  UInt  uiMaxCuDepth  = m_apcPicYuv[1]->getMaxCuDepth ();
+  m_apcPicYuvSynthDepth      = new TComPicYuv;
+  m_apcPicYuvSynthDepth      ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth );
+}
+#endif
+
 #if PARALLEL_MERGED_DEBLK
 Void
@@ -286,4 +368,43 @@
 }
 
+#if POZNAN_AVAIL_MAP
+Void
+TComPic::removeAvailabilityBuffer()
+{
+  if( m_apcPicYuvAvail )
+  {
+    m_apcPicYuvAvail->destroy();
+    delete m_apcPicYuvAvail;
+    m_apcPicYuvAvail  = NULL;
+  }
+}
+#endif
+
+#if POZNAN_SYNTH_VIEW
+Void
+TComPic::removeSynthesisBuffer()
+{
+  if( m_apcPicYuvSynth )
+  {
+    m_apcPicYuvSynth->destroy();
+    delete m_apcPicYuvSynth;
+    m_apcPicYuvSynth  = NULL;
+  }
+}
+#endif
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+Void
+TComPic::removeSynthesisDepthBuffer()
+{
+  if( m_apcPicYuvSynthDepth )
+  {
+    m_apcPicYuvSynthDepth->destroy();
+    delete m_apcPicYuvSynthDepth;
+    m_apcPicYuvSynthDepth  = NULL;
+  }
+}
+#endif
+
 #if PARALLEL_MERGED_DEBLK
 Void
@@ -351,2 +472,58 @@
 #endif
 
+#if POZNAN_AVAIL_MAP
+Void TComPic::checkSynthesisAvailability( TComDataCU*& rpcCU, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, Bool *&rpbCUSynthesied )
+{ 
+  rpbCUSynthesied[0] = true;
+  rpbCUSynthesied[1] = true;
+  rpbCUSynthesied[2] = true;
+  rpbCUSynthesied[3] = true;
+
+  if (!getPicYuvAvail())
+  {
+    rpbCUSynthesied[0] = false;
+    rpbCUSynthesied[1] = false;
+    rpbCUSynthesied[2] = false;
+    rpbCUSynthesied[3] = false;
+    return;    
+  }
+  
+  Int x, y;
+  Bool bAvailable = true;
+  Pel* pAvail  = getPicYuvAvail()->getLumaAddr ( iCuAddr, uiAbsZorderIdx );
+  Int CUHeight = g_uiMaxCUHeight >> uiPartDepth; //rpcCU->getHeight(uiAbsZorderIdx);
+  Int CUWidth  = g_uiMaxCUWidth  >> uiPartDepth; //rpcCU->getWidth(uiAbsZorderIdx);
+  
+  Int  iStride  = getPicYuvAvail()->getStride();
+  for ( y = ((CUHeight - 1) >> 1); y >= 0; y-- )
+  {
+    for ( x = ((CUWidth - 1) >> 1); x >= 0; x-- )
+    {
+      rpbCUSynthesied[0] &= (pAvail[x] != 0);
+    }
+    for ( x = CUWidth - 1; x >= ((CUWidth) >> 1); x-- )
+    {
+      rpbCUSynthesied[1] &= (pAvail[x] != 0);
+    }
+    pAvail += iStride;
+  }
+  //for ( y = CUHeight - 1; y >= ((CUHeight) >> 1); y-- )
+  for ( y = ((CUHeight - 1) >> 1); y >= 0; y-- ) //Owieczka
+  {
+    for ( x = ((CUWidth - 1) >> 1); x >= 0; x-- )
+    {
+      rpbCUSynthesied[2] &= (pAvail[x] != 0);
+    }
+    for ( x = CUWidth - 1; x >= ((CUWidth) >> 1); x-- )
+    {
+      rpbCUSynthesied[3] &= (pAvail[x] != 0);
+    }
+    pAvail += iStride;
+  }
+
+  //rpbCUSynthesied[0] = !rpbCUSynthesied[0];
+  //rpbCUSynthesied[1] = !rpbCUSynthesied[1];
+  //rpbCUSynthesied[2] = !rpbCUSynthesied[2];
+  //rpbCUSynthesied[3] = !rpbCUSynthesied[3];
+}
+#endif
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPic.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPic.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPic.h	(revision 28)
@@ -61,4 +61,16 @@
 
   TComPicYuv*           m_apcPicYuv[2];           //  Texture,  0:org / 1:rec
+
+#if POZNAN_AVAIL_MAP
+  TComPicYuv*           m_apcPicYuvAvail;         //  Availability Map - Does the given pixel can be synthesised in receiver
+#endif
+
+#if POZNAN_SYNTH_VIEW
+  TComPicYuv*           m_apcPicYuvSynth;         //  Sythesied image
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  TComPicYuv*           m_apcPicYuvSynthDepth;         //  Sythesied depth image
+#endif
+
 #if DEPTH_MAP_GENERATION
   TComPicYuv*           m_pcPredDepthMap;         //  estimated depth map
@@ -101,4 +113,9 @@
 #if HHI_INTERVIEW_SKIP
   TComPicYuv*           m_pcUsedPelsMap;
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double                m_dTexDqpAccordingToDepthOffset;
+  Double                m_dTexDqpAccordingToDepthMul;
+  Int                   m_iTexDqpAccordingToDepthTopBottomRow; 
 #endif
 
@@ -129,4 +146,15 @@
   TComPicYuv*   getPicYuvOrg()        { return  m_apcPicYuv[0]; }
   TComPicYuv*   getPicYuvRec()        { return  m_apcPicYuv[1]; }
+
+#if POZNAN_AVAIL_MAP
+  TComPicYuv*   getPicYuvAvail()      { return  m_apcPicYuvAvail; } //Owieczka - returns available map from other pic image
+#endif
+
+#if POZNAN_SYNTH_VIEW
+  TComPicYuv*   getPicYuvSynth()      { return  m_apcPicYuvSynth; } //Owieczka - returns synth form other pic in image
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  TComPicYuv*   getPicYuvSynthDepth() { return  m_apcPicYuvSynthDepth; };    //  Sythesied depth image
+#endif
 
 #if DEPTH_MAP_GENERATION
@@ -203,4 +231,13 @@
 
   Void          addOriginalBuffer       ();
+#if POZNAN_AVAIL_MAP
+  Void          addAvailabilityBuffer   ();
+#endif
+#if POZNAN_SYNTH_VIEW
+  Void          addSynthesisBuffer      ();
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Void          addSynthesisDepthBuffer ();
+#endif
 #if PARALLEL_MERGED_DEBLK
   Void          addDeblockBuffer        ();
@@ -221,4 +258,13 @@
 
   Void          removeOriginalBuffer    ();
+#if POZNAN_SYNTH_VIEW
+  Void          removeSynthesisBuffer   ();
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Void          removeSynthesisDepthBuffer ();
+#endif
+#if POZNAN_AVAIL_MAP
+  Void          removeAvailabilityBuffer();
+#endif
 #if PARALLEL_MERGED_DEBLK
   Void          removeDeblockBuffer     ();
@@ -235,4 +281,8 @@
 #if HHI_INTERVIEW_SKIP
   Void          removeUsedPelsMapBuffer ();
+#endif
+
+#if POZNAN_AVAIL_MAP
+  Void          checkSynthesisAvailability(  TComDataCU*& rpcBestCU, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, Bool *&rpbCUSynthesied);
 #endif
 
@@ -254,4 +304,12 @@
   const SEImessages* getSEIs() const { return m_SEIs; }
 
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double getTexDqpAccordingToDepthOffset( )      { return m_dTexDqpAccordingToDepthOffset;}
+  Double getTexDqpAccordingToDepthMul( )         { return m_dTexDqpAccordingToDepthMul;}
+  Int    getTexDqpAccordingToDepthTopBottomRow( ){ return m_iTexDqpAccordingToDepthTopBottomRow;}
+  Void   setTexDqpAccordingToDepthOffset      ( Double dTexDqpAccordingToDepthOffset    ){ m_dTextureCuDeltaQpOffset       = dTexDqpAccordingToDepthOffset; }
+  Void   setTexDqpAccordingToDepthMul         ( Double dTexDqpAccordingToDepthMul       ){ m_dTexDqpAccordingToDepthMul          = dTexDqpAccordingToDepthMul; }
+  Void   setTexDqpAccordingToDepthTopBottomRow( Int iTexDqpAccordingToDepthTopBottomRow ){ m_iTexDqpAccordingToDepthTopBottomRow = iTexDqpAccordingToDepthTopBottomRow; }  
+#endif 
 };// END CLASS DEFINITION TComPic
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicSym.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicSym.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicSym.h	(revision 28)
@@ -43,4 +43,8 @@
 
 // Include files
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif
+
 #include "CommonDef.h"
 #include "TComSlice.h"
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 28)
@@ -8,4 +8,5 @@
 #include <assert.h>
 #include <memory.h>
+#include <math.h>
 
 #ifdef __APPLE__
@@ -455,2 +456,46 @@
   }
 }
+#if POZNAN_NONLINEAR_DEPTH
+Void TComPicYuv::nonlinearDepthForward(TComPicYuv *pcPicDst, Float p)
+{
+  Int		x,y;
+  TComNonlinearDepthForward cNonlinearDepthFwd(p, g_uiBitIncrement, g_uiBitIncrement);
+
+  // Luma
+  Pel* pPelSrc = getLumaAddr();
+  Pel* pPelDst = pcPicDst->getLumaAddr();
+  for(y=0; y<m_iPicHeight; y++)
+	{
+    for(x=0; x<m_iPicWidth; x++)
+    {
+      pPelDst[x] = (Pel)( cNonlinearDepthFwd(pPelSrc[x]) + 0.5);
+    }
+    pPelDst += pcPicDst->getStride();
+    pPelSrc += getStride();
+  }
+  // Chroma
+  copyToPicCb(pcPicDst);
+  copyToPicCr(pcPicDst);
+}
+Void TComPicYuv::nonlinearDepthBackward(TComPicYuv *pcPicDst, Float p)
+{
+  Int		x,y;
+  TComNonlinearDepthBackward cNonlinearDepthBwd(p, g_uiBitIncrement, g_uiBitIncrement);
+
+  // Luma
+  Pel* pPelSrc = getLumaAddr();
+  Pel* pPelDst = pcPicDst->getLumaAddr();
+  for(y=0; y<m_iPicHeight; y++)
+	{
+    for(x=0; x<m_iPicWidth; x++)
+    {
+      pPelDst[x] = (Pel)( cNonlinearDepthBwd(pPelSrc[x]) + 0.5);
+    }
+    pPelDst += pcPicDst->getStride();
+    pPelSrc += getStride();
+  }
+  // Chroma
+  copyToPicCb(pcPicDst);
+  copyToPicCr(pcPicDst);
+}
+#endif
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPicYuv.h	(revision 28)
@@ -44,4 +44,54 @@
 #include "CommonDef.h"
 
+#if POZNAN_NONLINEAR_DEPTH
+
+#include <math.h>
+
+class TComNonlinearDepthForward // OLGIERD - Z-NL-Power conversion
+{
+private:
+  Double m_fMul;
+  Float m_fPower;
+
+public:
+
+  TComNonlinearDepthForward(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement)
+  {
+    m_fPower = fPower;
+    Double fPostMul = (1<<(8+iOutputBitIncrement))-1; // OLGIERD ToDo - should be or not?
+    Double fPreMul  = 1.0/((1<<(8+iInputBitIncrement))-1);
+    m_fMul = fPostMul*pow(fPreMul,(Double)fPower);
+  };
+
+  inline Double operator() (Double Value)
+  {    
+    if (Value<0) return -pow( -Value,(Double)m_fPower)*m_fMul;
+    return pow(Value,(Double)m_fPower)*m_fMul;
+  };
+};
+
+class TComNonlinearDepthBackward // OLGIERD - Z-NL-Power conversion
+{
+private:
+  Double m_fMul;
+  Float m_fPower;
+
+public:
+
+  TComNonlinearDepthBackward(Float fPower, Int iInputBitIncrement, Int iOutputBitIncrement) 
+  {     
+    m_fPower = fPower = 1.0/fPower;
+    Double fPostMul = (1<<(8+iOutputBitIncrement))-1; // OLGIERD ToDo - should be or not?
+    Double fPreMul  = 1.0/((1<<(8+iInputBitIncrement))-1);
+    m_fMul = fPostMul*pow(fPreMul,(Double)fPower);
+  };
+
+  inline Double operator() (Double Value)
+  {    
+    if (Value<0) return -pow( -Value,(Double)m_fPower)*m_fMul;
+    return pow(Value,(Double)m_fPower)*m_fMul;
+  };
+};
+#endif
 // ====================================================================================================================
 // Class definition
@@ -175,4 +225,8 @@
   Void  setChromaTo  ( Pel pVal );  
 
+#if POZNAN_NONLINEAR_DEPTH
+  Void nonlinearDepthForward(TComPicYuv *pcPicDst, Float p);
+  Void nonlinearDepthBackward(TComPicYuv *pcPicDst, Float p);
+#endif
 };// END CLASS DEFINITION TComPicYuv
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.cpp	(revision 28)
@@ -1521,4 +1521,16 @@
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
 
+#if POZNAN_DBMP
+	if(pcCU->getMergeIndex(uiPartAddr)==POZNAN_DBMP_MRG_CAND) 
+	{
+#if DEPTH_MAP_GENERATION
+		motionCompensation_DBMP( pcCU, pcYuvPred, eRefPicList, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
+#else
+		motionCompensation_DBMP( pcCU, pcYuvPred, eRefPicList, iPartIdx );
+#endif
+		return;
+	}
+#endif
+
 #if DEPTH_MAP_GENERATION
     if( bPrdDepthMap )
@@ -1558,4 +1570,16 @@
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
 
+#if POZNAN_DBMP
+	if(pcCU->getMergeIndex(uiPartAddr)==POZNAN_DBMP_MRG_CAND) 
+	{
+#if DEPTH_MAP_GENERATION
+		motionCompensation_DBMP( pcCU, pcYuvPred, eRefPicList, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
+#else
+		motionCompensation_DBMP( pcCU, pcYuvPred, eRefPicList, iPartIdx );
+#endif
+		continue;
+	}
+#endif
+
 #if DEPTH_MAP_GENERATION
     if( bPrdDepthMap )
@@ -1591,4 +1615,214 @@
   return;
 }
+
+#if POZNAN_DBMP
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::motionCompensation_DBMP ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
+#else
+Void TComPrediction::motionCompensation_DBMP ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
+#endif
+{
+  if(!pcCU->getSlice()->getMP()->isDBMPEnabled()) return;
+
+  Int         iPartIdxOrg = iPartIdx;
+  Int         iWidth;
+  Int         iHeight;
+  UInt        uiPartAddr;
+
+  Int		  x,y;
+  Int		  px,py,iCUBaseX,iCUBaseY;
+  Int		  ref_frame0, ref_frame1;
+  Int		  ref_frame0_idx, ref_frame1_idx;
+  TComMv	  mv0,mv1;
+  
+  Int		  ref_frame0_idx_2nd, ref_frame1_idx_2nd;
+  TComMv	  mv0_2nd,mv1_2nd;
+
+  Pel* piDstCb;
+  Pel* piDstCr;
+  Pel aiUTab[MAX_CU_SIZE];
+  Pel aiVTab[MAX_CU_SIZE];
+  Pel iULast;
+  Pel iVLast;
+  Pel iTemp;
+
+  TComMP* pcMP = pcCU->getSlice()->getMP();
+  UInt uiViewId = pcCU->getSlice()->getSPS()->getViewId();
+  Bool bIsDepth = pcCU->getSlice()->getSPS()->isDepth();
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+  UInt uiPointCnt;
+#endif
+    
+  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ )
+  {
+	if ( iPartIdxOrg >= 0 ) iPartIdx = iPartIdxOrg;
+
+    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
+
+	//get motion data used for no-MP predicted points
+#if POZNAN_DBMP_CALC_PRED_DATA
+	ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+	mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+
+	ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
+	mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+#else
+	ref_frame0_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr);
+	mv0_2nd = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
+
+	ref_frame1_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr);
+	mv1_2nd = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
+#endif
+
+	iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiPartAddr] ];
+	iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiPartAddr] ];
+
+#if DEPTH_MAP_GENERATION
+    if( bPrdDepthMap )
+    {
+      iWidth  >>= uiSubSampExpX;
+      iHeight >>= uiSubSampExpY;
+    }
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+	uiPointCnt = 0;
+#endif
+
+	for( py = 0; py < iHeight; py++)
+	{
+		for( px = 0; px < iWidth; px++)
+		{
+#if DEPTH_MAP_GENERATION
+			if( bPrdDepthMap )
+			{
+				x = iCUBaseX+(px<<uiSubSampExpX);
+				y = iCUBaseY+(py<<uiSubSampExpY);
+			}
+			else
+#endif
+			{
+				x = iCUBaseX+px;
+				y = iCUBaseY+py;
+			}
+
+			pcMP->getDBMPPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, 
+										ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd);
+
+			pcCU->getCUMvField(REF_PIC_LIST_0)->setRefIdx(ref_frame0_idx, uiPartAddr);
+			pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv0, uiPartAddr );
+
+			pcCU->getCUMvField(REF_PIC_LIST_1)->setRefIdx(ref_frame1_idx, uiPartAddr);
+			pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv1, uiPartAddr );
+
+			if ( eRefPicList != REF_PIC_LIST_X )
+			{
+#if DEPTH_MAP_GENERATION
+			  xPredInterUni_DBMP (pcCU, uiPartAddr, px, py, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
+#else
+			  xPredInterUni_DBMP (pcCU, uiPartAddr, px, py, eRefPicList, pcYuvPred, iPartIdx );
+#endif
+#ifdef WEIGHT_PRED
+			  if ( pcCU->getSlice()->getPPS()->getUseWP() )
+			  {
+			    xWeightedPredictionUni_DBMP( pcCU, pcYuvPred, uiPartAddr, px, py, eRefPicList, pcYuvPred, iPartIdx );
+			  }
+#endif
+			}
+			else
+			{
+#if DEPTH_MAP_GENERATION
+			  xPredInterBi_DBMP  (pcCU, uiPartAddr, px, py, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
+#else
+			  xPredInterBi_DBMP  (pcCU, uiPartAddr, px, py, pcYuvPred, iPartIdx );
+#endif
+			}			
+
+			if(!pcCU->getSlice()->getSPS()->isDepth()) // Chroma check only for non depth 
+			{
+			piDstCb = pcYuvPred->getCbAddr( uiPartAddr ) + (py>>1)*pcYuvPred->getCStride();
+			piDstCr = pcYuvPred->getCrAddr( uiPartAddr ) + (py>>1)*pcYuvPred->getCStride();
+
+			//Chroma decimation 16x16 -> 8x8:
+			if(py%2 && px%2)
+			{
+				iTemp = (aiUTab[px-1] + aiUTab[px] + iULast + piDstCb[px>>1] + 2)>>2;
+				aiUTab[px-1] = iULast;
+				iULast = piDstCb[px>>1];
+				piDstCb[px>>1] = iTemp;
+
+				iTemp = (aiVTab[px-1] + aiVTab[px] + iVLast + piDstCr[px>>1] + 2)>>2;
+				aiVTab[px-1] = iVLast;
+				iVLast = piDstCr[px>>1];
+				piDstCr[px>>1] = iTemp;
+			}
+			else
+			{
+				aiUTab[(px==0)? iWidth-1 : (px-1)] = iULast;	
+				iULast = piDstCb[px>>1];
+
+				aiVTab[(px==0)? iWidth-1 : (px-1)] = iVLast;				
+				iVLast = piDstCr[px>>1];
+			}	
+			}
+
+#if !POZNAN_DBMP_COMPRESS_ME_DATA
+			//save motion data for every CU point
+#if DEPTH_MAP_GENERATION
+			if( !bPrdDepthMap )
+#endif
+			{
+				pcMP->setL0RefPOC(uiViewId,bIsDepth,x,y,ref_frame0);
+				pcMP->setL0MvX(uiViewId,bIsDepth,x,y,mv0.getHor());
+				pcMP->setL0MvY(uiViewId,bIsDepth,x,y,mv0.getVer());
+
+				pcMP->setL1RefPOC(uiViewId,bIsDepth,x,y,ref_frame1);
+				pcMP->setL1MvX(uiViewId,bIsDepth,x,y,mv1.getHor());
+				pcMP->setL1MvY(uiViewId,bIsDepth,x,y,mv1.getVer());
+			}
+#endif
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+#if DEPTH_MAP_GENERATION
+			if( !bPrdDepthMap )
+#endif
+			{
+				pcMP->getTempL0RefIdx()[uiPointCnt] = ref_frame0_idx;
+				pcMP->getTempL0MvX()[uiPointCnt] = mv0.getHor();
+				pcMP->getTempL0MvY()[uiPointCnt] = mv0.getVer();
+
+				pcMP->getTempL1RefIdx()[uiPointCnt] = ref_frame1_idx;
+				pcMP->getTempL1MvX()[uiPointCnt] = mv1.getHor();
+				pcMP->getTempL1MvY()[uiPointCnt] = mv1.getVer();			
+			}
+			uiPointCnt++;
+#endif
+
+		}
+	}
+
+	//set motion data representing CU with DBMP 
+#if DEPTH_MAP_GENERATION
+	if( !bPrdDepthMap )
+#endif
+	{
+		PartSize ePartSize = pcCU->getPartitionSize( uiPartAddr ); //PartSize ePartSize = pcCU->getPartitionSize( 0 );
+#if POZNAN_DBMP_CALC_PRED_DATA
+		pcMP->xCalcDBMPPredData(uiPointCnt, ref_frame0_idx, mv0, ref_frame1_idx, mv1);
+		
+		pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( mv0, ref_frame0_idx, ePartSize, uiPartAddr, iPartIdx, 0 );		
+		pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( mv1, ref_frame1_idx, ePartSize, uiPartAddr, iPartIdx, 0 );
+#else
+		pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( mv0_2nd, ref_frame0_idx_2nd, ePartSize, uiPartAddr, iPartIdx, 0 );
+		pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( mv1_2nd, ref_frame1_idx_2nd, ePartSize, uiPartAddr, iPartIdx, 0 );
+#endif
+	}
+
+	if ( iPartIdxOrg >= 0 ) break;
+  }
+  return;
+}
+#endif
 
 #if HIGH_ACCURACY_BI
@@ -2135,4 +2369,557 @@
 }
 
+
+
+#if POZNAN_DBMP
+
+#if HIGH_ACCURACY_BI
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::xPredInterUni_DBMP ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi )
+#else
+Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi )
+#endif
+#else
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
+#else
+Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx )
+#endif
+#endif
+{
+  Int         iRefIdx     = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           assert (iRefIdx >= 0);
+  TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+  pcCU->clipMv(cMv);
+
+#if DEPTH_MAP_GENERATION
+  if( bPrdDepthMap )
+  {
+	UInt uiRShift = 0;
+	xPredInterPrdDepthMap_DBMP( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iPosX, iPosY, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift );
+    return;
+  }
+#endif
+
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  if( pcCU->getSlice()->getSPS()->isDepth() )
+  {
+#if HIGH_ACCURACY_BI
+    UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 );
+#else
+    UInt uiRShift = 0;
+#endif
+#if DEPTH_MAP_GENERATION
+    xPredInterPrdDepthMap_DBMP( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, 0, 0, rpcYuvPred, uiRShift );
+#else
+    xPredInterPrdDepthMap_DBMP( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred, uiRShift );
+#endif
+  }
+  else
+  {
+#endif
+#if HIGH_ACCURACY_BI
+  if(!bi)
+  {
+    xPredInterLumaBlk_DBMP ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+  else
+  {
+    xPredInterLumaBlk_DBMP_ha  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+#else
+  xPredInterLumaBlk_DBMP       ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+#endif
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  }
+#endif
+
+#if HIGH_ACCURACY_BI
+  if (!bi)
+  {
+	xPredInterChromaBlk_DBMP     ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+  else
+  {
+	xPredInterChromaBlk_DBMP_ha ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec()    , uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+  }
+#else
+  xPredInterChromaBlk_DBMP     ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iPosX, iPosY, rpcYuvPred );
+#endif
+}
+
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::xPredInterBi_DBMP ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
+#else
+Void TComPrediction::xPredInterBi_DBMP ( TComDataCU* pcCU, UInt uiPartAddr, Int iPosX, Int iPosY, TComYuv*& rpcYuvPred, Int iPartIdx )
+#endif
+{
+  TComYuv* pcMbYuv;
+  Int      iRefIdx[2] = {-1, -1};
+
+  for ( Int iRefList = 0; iRefList < 2; iRefList++ )
+  {
+    RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+    iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
+
+    if ( iRefIdx[iRefList] < 0 )
+    {
+      continue;
+    }
+
+    assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );
+
+    pcMbYuv = &m_acYuvPred[iRefList];
+#if HIGH_ACCURACY_BI
+    if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
+#if DEPTH_MAP_GENERATION
+      xPredInterUni_DBMP ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
+#else
+      xPredInterUni_DBMP ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx, true );
+#endif
+    else
+#if DEPTH_MAP_GENERATION
+      xPredInterUni_DBMP ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
+#else
+      xPredInterUni_DBMP ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx );
+#endif
+#else
+#if DEPTH_MAP_GENERATION
+    xPredInterUni_DBMP ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
+#else
+    xPredInterUni_DBMP ( pcCU, uiPartAddr, iPosX, iPosY, eRefPicList, pcMbYuv, iPartIdx );
+#endif
+#endif
+  }
+
+#ifdef WEIGHT_PRED
+  if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() )
+  {
+    xWeightedPredictionBi_DBMP( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iPosX, iPosY, rpcYuvPred );
+  }
+  else
+#endif
+
+#if DEPTH_MAP_GENERATION
+  if ( bPrdDepthMap )
+  {
+    xWeightedAveragePdm_DBMP( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iPosX, iPosY, rpcYuvPred, uiSubSampExpX, uiSubSampExpY );
+  }
+  else
+  {
+    xWeightedAverage_DBMP( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iPosX, iPosY, rpcYuvPred );
+  }
+#else
+  xWeightedAverage_DBMP( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iPosX, iPosY, rpcYuvPred );
+#endif
+}
+
+Void 
+#if DEPTH_MAP_GENERATION
+TComPrediction::xPredInterPrdDepthMap_DBMP( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift )
+#else
+TComPrediction::xPredInterPrdDepthMap_DBMP( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv, UInt uiRShift )
+#endif
+{
+#if DEPTH_MAP_GENERATION
+  Int     iShiftX     = 2 + uiSubSampExpX;
+  Int     iShiftY     = 2 + uiSubSampExpY;
+  Int     iAddX       = ( 1 << iShiftX ) >> 1;
+  Int     iAddY       = ( 1 << iShiftY ) >> 1;
+  Int     iHor        = ( pcMv->getHor() + iAddX ) >> iShiftX;
+  Int     iVer        = ( pcMv->getVer() + iAddY ) >> iShiftY;
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  if( pcCU->getSlice()->getSPS()->isDepth() )
+  {
+    iHor = pcMv->getHor();
+    iVer = pcMv->getVer();
+  }
+#endif
+  Int     iRefStride  = pcPicYuvRef->getStride();
+  Int     iDstStride  = rpcYuv->getStride();
+  Int     iRefOffset  = iHor + iVer * iRefStride;
+#else
+  Int     iFPelMask   = ~3;
+  Int     iRefStride  = pcPicYuvRef->getStride();
+  Int     iDstStride  = rpcYuv->getStride();
+  Int     iHor        = ( pcMv->getHor() + 2 ) & iFPelMask;
+  Int     iVer        = ( pcMv->getVer() + 2 ) & iFPelMask;
+#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
+  if( pcCU->getSlice()->getSPS()->isDepth() )
+  {
+    iHor = pcMv->getHor() * 4;
+    iVer = pcMv->getVer() * 4;
+  }
+#endif
+  Int     ixFrac      = iHor & 0x3;
+  Int     iyFrac      = iVer & 0x3;
+  Int     iRefOffset  = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;
+#endif
+
+  Pel*    piRefY      = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+  Pel*    piDstY      = rpcYuv->getLumaAddr( uiPartAddr );
+
+  piDstY[ iPosY*iDstStride + iPosX ] = piRefY[ iPosY*iRefStride + iPosX ] << uiRShift;
+}
+
+
+#if HIGH_ACCURACY_BI
+
+Void  TComPrediction::xPredInterLumaBlk_DBMP_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride = pcPicYuvRef->getStride();
+  Int     iDstStride = rpcYuv->getStride();
+
+  Int     iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride;
+  Pel*    piRefY     = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Int     ixFrac  = pcMv->getHor() & 0x3;
+  Int     iyFrac  = pcMv->getVer() & 0x3;
+
+  Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr );
+  UInt shiftNum = 14-g_uiBitDepth-g_uiBitIncrement;
+
+  piDstY += iPosY*iDstStride+iPosX;
+  piRefY += iPosY*iRefStride+iPosX;
+
+  //  Integer point
+  if ( ixFrac == 0 && iyFrac == 0 )
+  {
+    *piDstY = (*piRefY)<<shiftNum;
+    return;
+  }
+
+  Int iWidth = 1;
+  Int iHeight = 1;
+
+  //  Half-pel horizontal
+  if ( ixFrac == 2 && iyFrac == 0 )
+  {
+    xCTI_FilterHalfHor_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Half-pel vertical
+  if ( ixFrac == 0 && iyFrac == 2 )
+  {
+    xCTI_FilterHalfVer_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  Int   iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride();
+  Int*  piExtY     = m_piYuvExt;//m_cYuvExt.getLumaAddr();
+
+  //  Half-pel center
+  if ( ixFrac == 2 && iyFrac == 2 )
+  {
+    xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+    xCTI_FilterHalfHor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Quater-pel horizontal
+  if ( iyFrac == 0)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+  if ( iyFrac == 2 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterHalfVer (piRefY -3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor_ha (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor_ha (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  //  Quater-pel vertical
+  if( ixFrac == 0 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  if( ixFrac == 2 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver (piRefY -3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  /// Quarter-pel center
+  if ( iyFrac == 1)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+
+      return;
+    }
+  }
+  if ( iyFrac == 3 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor_ha (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+}
+
+#endif
+
+Void  TComPrediction::xPredInterLumaBlk_DBMP( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride = pcPicYuvRef->getStride();
+  Int     iDstStride = rpcYuv->getStride();
+
+  Int     iRefOffset = ( pcMv->getHor() >> 2 ) + ( pcMv->getVer() >> 2 ) * iRefStride;
+  Pel*    piRefY     = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Int     ixFrac  = pcMv->getHor() & 0x3;
+  Int     iyFrac  = pcMv->getVer() & 0x3;
+
+  Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr );
+  
+  piDstY += iPosY*iDstStride+iPosX;
+  piRefY += iPosY*iRefStride+iPosX;
+
+  //  Integer point
+  if ( ixFrac == 0 && iyFrac == 0 )
+  {
+    ::memcpy(piDstY, piRefY, sizeof(Pel));
+    return;
+  }
+
+  Int iWidth = 1;
+  Int iHeight = 1;
+
+  //  Half-pel horizontal
+  if ( ixFrac == 2 && iyFrac == 0 )
+  {
+    xCTI_FilterHalfHor ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Half-pel vertical
+  if ( ixFrac == 0 && iyFrac == 2 )
+  {
+    xCTI_FilterHalfVer ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  Int   iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride();
+  Int*  piExtY     = m_piYuvExt;//m_cYuvExt.getLumaAddr();
+
+  //  Half-pel center
+  if ( ixFrac == 2 && iyFrac == 2 )
+  {
+
+    xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+    xCTI_FilterHalfHor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+    return;
+  }
+
+  //  Quater-pel horizontal
+  if ( iyFrac == 0)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+  if ( iyFrac == 2 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterHalfVer (piRefY -3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterHalfVer (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor (piExtY + 3,  iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  //  Quater-pel vertical
+  if( ixFrac == 0 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  if( ixFrac == 2 )
+  {
+    if( iyFrac == 1 )
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if( iyFrac == 3 )
+    {
+      xCTI_FilterQuarter1Ver (piRefY -3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterHalfHor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+
+  /// Quarter-pel center
+  if ( iyFrac == 1)
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter0Ver (piRefY - 3,  iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+  if ( iyFrac == 3 )
+  {
+    if ( ixFrac == 1)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter0Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+    if ( ixFrac == 3)
+    {
+      xCTI_FilterQuarter1Ver (piRefY - 3,  iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY );
+      xCTI_FilterQuarter1Hor (piExtY + 3,  iExtStride, 1, iWidth    , iHeight, iDstStride, 1, piDstY );
+      return;
+    }
+  }
+}
+
+#if HIGH_ACCURACY_BI
+Void TComPrediction::xPredInterChromaBlk_DBMP_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride  = pcPicYuvRef->getCStride();
+  Int     iDstStride  = rpcYuv->getCStride();
+
+  Int     iRefOffset  = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride;
+
+  Pel*    piRefCb     = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+  Pel*    piRefCr     = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr );
+  Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr );
+
+  Int     ixFrac  = pcMv->getHor() & 0x7;
+  Int     iyFrac  = pcMv->getVer() & 0x7;
+  UInt    uiCWidth  = 1;
+  UInt    uiCHeight = 1;
+
+  piDstCb += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piDstCr += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piRefCb += (iPosY>>1)*iRefStride+(iPosX>>1);
+  piRefCr += (iPosY>>1)*iRefStride+(iPosX>>1);
+
+  xDCTIF_FilterC_ha(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  xDCTIF_FilterC_ha(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  return;
+}
+#endif
+
+//--
+Void TComPrediction::xPredInterChromaBlk_DBMP( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, TComYuv*& rpcYuv )
+{
+  Int     iRefStride  = pcPicYuvRef->getCStride();
+  Int     iDstStride  = rpcYuv->getCStride();
+
+  Int     iRefOffset  = (pcMv->getHor() >> 3) + (pcMv->getVer() >> 3) * iRefStride;
+
+  Pel*    piRefCb     = pcPicYuvRef->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+  Pel*    piRefCr     = pcPicYuvRef->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
+
+  Pel* piDstCb = rpcYuv->getCbAddr( uiPartAddr );
+  Pel* piDstCr = rpcYuv->getCrAddr( uiPartAddr );
+
+  Int     ixFrac  = pcMv->getHor() & 0x7;
+  Int     iyFrac  = pcMv->getVer() & 0x7;
+  UInt    uiCWidth  = 1;
+  UInt    uiCHeight = 1;
+
+  piDstCb += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piDstCr += (iPosY>>1)*iDstStride+(iPosX>>1);
+  piRefCb += (iPosY>>1)*iRefStride+(iPosX>>1);
+  piRefCr += (iPosY>>1)*iRefStride+(iPosX>>1);
+
+  xDCTIF_FilterC(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  xDCTIF_FilterC(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac);
+  return;
+}
+
+#endif
+
+
 Void  TComPrediction::xDCTIF_FilterC ( Pel*  piRefC, Int iRefStride,Pel*  piDstC,Int iDstStride,
                                        Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac)
@@ -2260,4 +3047,53 @@
   }
 }
+
+#if POZNAN_DBMP
+
+#if DEPTH_MAP_GENERATION
+Void TComPrediction::xWeightedAveragePdm_DBMP( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iPosX, Int iPosY, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
+  {
+    rpcYuvDst->addAvgPdm_DBMP( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iPosX, iPosY, uiSubSampExpX, uiSubSampExpY );
+  }
+  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
+  {
+    pcYuvSrc0->copyPartToPartYuvPdm_DBMP( rpcYuvDst, uiPartIdx, iPosX, iPosY, uiSubSampExpX, uiSubSampExpY );
+  }
+  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
+  {
+    pcYuvSrc1->copyPartToPartYuvPdm_DBMP( rpcYuvDst, uiPartIdx, iPosX, iPosY, uiSubSampExpX, uiSubSampExpY );
+  }
+  else
+  {
+    assert (0);
+  }
+}
+#endif
+
+Void TComPrediction::xWeightedAverage_DBMP( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iPosX, Int iPosY, TComYuv*& rpcYuvDst )
+{
+  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
+  {
+#ifdef ROUNDING_CONTROL_BIPRED
+    rpcYuvDst->addAvg_DBMP( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iPosX, iPosY, pcCU->getSlice()->isRounding());
+#else
+    rpcYuvDst->addAvg_DBMP( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iPosX, iPosY );
+#endif
+  }
+  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
+  {
+    pcYuvSrc0->copyPartToPartYuv_DBMP( rpcYuvDst, uiPartIdx, iPosX, iPosY );
+  }
+  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
+  {
+    pcYuvSrc1->copyPartToPartYuv_DBMP( rpcYuvDst, uiPartIdx, iPosX, iPosY );
+  }
+  else
+  {
+    assert (0);
+  }
+}
+#endif
 
 // AMVP
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComPrediction.h	(revision 28)
@@ -52,4 +52,8 @@
 #endif
 
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif
+
 // ====================================================================================================================
 // Class definition
@@ -124,4 +128,40 @@
 #endif
 
+#if POZNAN_DBMP
+#if HIGH_ACCURACY_BI
+#if DEPTH_MAP_GENERATION
+  Void xPredInterUni_DBMP       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0, Bool bi=false          );
+#else
+  Void xPredInterUni_DBMP       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi=false          );
+#endif
+#else
+#if DEPTH_MAP_GENERATION
+  Void xPredInterUni_DBMP       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0 );
+#else
+  Void xPredInterUni_DBMP       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx          );
+#endif
+#endif
+#if DEPTH_MAP_GENERATION
+  Void xPredInterBi_DBMP        ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap );
+  Void xPredInterPrdDepthMap_DBMP( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift );
+#else
+  Void xPredInterBi_DBMP             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY,                         TComYuv*& rpcYuvPred, Int iPartIdx );
+  Void xPredInterPrdDepthMap_DBMP    ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv, UInt uiRShift );
+#endif
+  
+  Void xPredInterLumaBlk_DBMP   ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv );
+  Void xPredInterChromaBlk_DBMP ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv );
+  
+#if DEPTH_MAP_GENERATION
+  Void xWeightedAveragePdm_DBMP      ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iPosX, Int iPosY, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY );
+#endif
+  Void xWeightedAverage_DBMP         ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iPosX, Int iPosY, TComYuv*& rpcYuvDst ); 
+  
+#if HIGH_ACCURACY_BI
+  Void xPredInterLumaBlk_DBMP_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv );
+  Void xPredInterChromaBlk_DBMP_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv                            );
+#endif
+#endif
+
 #if HHI_DMM_WEDGE_INTRA
   Void xPredIntraWedgeFull       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1 = 0, Int iDeltaDC2 = 0 );
@@ -160,4 +200,13 @@
 #else
   Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
+#endif
+  
+#if POZNAN_DBMP
+#if DEPTH_MAP_GENERATION
+  Void motionCompensation_DBMP         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0 );
+#else
+  Void motionCompensation_DBMP         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
+#endif
+  
 #endif
   
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComResidualGenerator.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 28)
@@ -306,4 +306,9 @@
     xSetRecResidualInterCU( pcSubCU, pcSubRes );
     break;
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  case MODE_SYNTH:
+    xSetRecResidualIntraCU( pcSubCU, pcSubRes ); //MayBe it should be seperate function
+    break;
+#endif
   default:
     AOT( true );
@@ -336,5 +341,9 @@
   UInt    uiLumaTrMode, uiChromaTrMode;
   pcCU->convertTransIdx             ( 0, pcCU->getTransformIdx( 0 ), uiLumaTrMode, uiChromaTrMode );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant        ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(0/*uiAbsPartIdx*/, false), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
   m_pcTrQuant->setQPforQuant        ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pRes, 0, pcCUResidual->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
   // chroma Cb
@@ -343,5 +352,9 @@
   piCoeff     = pcCU->getCoeffCb();
   pRes        = pcCUResidual->getCbAddr();
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant        ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(0/*uiAbsPartIdx*/, false), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
   m_pcTrQuant->setQPforQuant        ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pRes, 0, pcCUResidual->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
   // chroma Cr
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.cpp	(revision 28)
@@ -89,8 +89,15 @@
   initWpAcDcParam();
 #endif
+
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
 TComSlice::~TComSlice()
 {
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
@@ -681,4 +688,13 @@
 #endif
 
+#if POZNAN_DBMP
+  m_uiDBMP = 0;
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  m_uiUseCUSkip = 0;
+#endif
+
+
   // AMVP parameter
   ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) );
@@ -730,4 +746,10 @@
     }
   }
+#if POZNAN_NONLINEAR_DEPTH
+  m_fDepthPower = 1.0;
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_bUseTexDqpAccordingToDepth = false;
+#endif
 }
 
@@ -745,4 +767,7 @@
   ::memset( m_aaiCodedScale,  0x00, sizeof( m_aaiCodedScale  ) );
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
+#if POZNAN_NONLINEAR_DEPTH
+  m_fDepthPower = 1.0;
+#endif
 }
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComSlice.h	(revision 28)
@@ -57,4 +57,9 @@
 #endif
 
+#if POZNAN_MP
+//#include "../TLibCommon/TComMP.h"
+class TComMP;
+#endif
+
 // ====================================================================================================================
 // Class definition
@@ -148,4 +153,12 @@
 #endif
 
+#if POZNAN_DBMP
+  UInt  m_uiDBMP;
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  UInt  m_uiUseCUSkip;
+#endif
+
 #if DEPTH_MAP_GENERATION
   TComDepthMapGenerator* m_pcDepthMapGenerator;
@@ -153,4 +166,15 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   TComResidualGenerator* m_pcResidualGenerator;
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+  Float  m_fDepthPower;
+#endif
+
+#if POZNAN_MP
+  TComMP* m_pcMP;
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Bool   m_bUseTexDqpAccordingToDepth;
 #endif
 
@@ -208,5 +232,9 @@
 
   // Tool list
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Bool getUseALF      ()         { return (getViewId()>0)?false:m_bUseALF;}  //todo fix ALF
+#else
   Bool getUseALF      ()         { return m_bUseALF;        }
+#endif
   Bool getUseDQP      ()         { return m_bUseDQP;        }
 
@@ -266,5 +294,9 @@
 #if MTK_SAO
   Void setUseSAO                  (Bool bVal)  {m_bUseSAO = bVal;}
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU //todo fix SAO
+  Bool getUseSAO     ()         { return (getViewId()>0)?false:m_bUseSAO;}
+#else
   Bool getUseSAO                  ()           {return m_bUseSAO;}
+#endif
 #endif
 
@@ -282,4 +314,12 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   Void  setMultiviewResPredMode  ( UInt uiResPrdMode ) { m_uiMultiviewResPredMode = uiResPrdMode; }
+#endif
+
+#if POZNAN_DBMP
+  Void  setDBMP                  ( UInt uiDBMP )       { m_uiDBMP = uiDBMP; }
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Void  setUseCUSkip                ( UInt uiUseCUSkip )     { m_uiUseCUSkip = uiUseCUSkip; }
 #endif
 
@@ -297,4 +337,12 @@
 #endif
 
+#if POZNAN_DBMP
+  UInt  getDBMP                  ()          { return m_uiDBMP;   }
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  UInt  getUseCUSkip                ()          { return m_uiUseCUSkip;   }
+#endif
+
 #if DEPTH_MAP_GENERATION
   Void                    setDepthMapGenerator( TComDepthMapGenerator* pcDepthMapGenerator )  { m_pcDepthMapGenerator = pcDepthMapGenerator; }
@@ -304,4 +352,14 @@
   Void                    setResidualGenerator( TComResidualGenerator* pcResidualGenerator )  { m_pcResidualGenerator = pcResidualGenerator; }
   TComResidualGenerator*  getResidualGenerator()                                              { return m_pcResidualGenerator; }
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+  inline Void    setDepthPower(Float p)   {m_fDepthPower = p;}
+  inline Float	 getDepthPower()          {return m_fDepthPower;}
+#else
+  inline Float	 getDepthPower()          {return 1.0f;}
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Void setUseTexDqpAccordingToDepth    (Bool bVal)  {m_bUseTexDqpAccordingToDepth = bVal;}
+  Bool getUseTexDqpAccordingToDepth    ()           {return m_bUseTexDqpAccordingToDepth;}
 #endif
 };
@@ -448,7 +506,15 @@
 #endif
 
+#if POZNAN_MP
+  TComMP* m_pcMP;
+#endif
+
 public:
   TComSlice();
+#if POZNAN_MP
+  ~TComSlice();
+#else
   virtual ~TComSlice();
+#endif
 
   Void      initSlice       ();
@@ -614,4 +680,9 @@
 #endif
 
+#if POZNAN_MP
+  Void setMP(TComMP* pcMP) { m_pcMP = pcMP; }
+  TComMP* getMP() { return m_pcMP; }
+#endif
+
 protected:
 #if 0
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.cpp	(revision 28)
@@ -393,4 +393,160 @@
 }
 
+#if POZNAN_DBMP
+
+Void TComWeightPrediction::addWeightBi_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = rpcYuvDst->getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = rpcYuvDst->getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = rpcYuvDst->getCrAddr  ( iPartUnitIdx );
+  
+  // Luma : --------------------------------------------
+  Int w0      = wp0[0].w;
+  Int o0      = wp0[0].o;
+  Int offset  = wp0[0].offset;
+  Int shiftNum = 14 - (g_uiBitDepth + g_uiBitIncrement);
+  Int shift   = wp0[0].shift + shiftNum;
+  Int round   = (1<<(shift-1)) * bRound;
+  Int w1      = wp1[0].w;
+  Int o1      = wp1[0].o;
+
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = rpcYuvDst->getStride();
+  
+  pDstY[iPosY*iDstStride+iPosX] = weightBidir(w0,pSrcY0[iPosY*iSrc0Stride+iPosX], w1,pSrcY1[iPosY*iSrc1Stride+iPosX], round, shift, offset);
+   
+  // Chromas : --------------------------------------------
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = rpcYuvDst->getCStride();
+  
+  iPosX = iPosX>>1;
+  iPosY = iPosY>>1;
+
+  // Chroma U : --------------------------------------------
+  w0      = wp0[1].w;
+  o0      = wp0[1].o;
+  offset  = wp0[1].offset;
+  shift   = wp0[1].shift + shiftNum;
+  round   = (1<<(shift-1));
+  w1      = wp1[1].w;
+  o1      = wp1[1].o;
+  
+  pDstU[iPosY*iDstStride+iPosX] = weightBidir(w0,pSrcU0[iPosY*iSrc0Stride+iPosX], w1,pSrcU1[iPosY*iSrc1Stride+iPosX], round, shift, offset);
+
+  // Chroma V : --------------------------------------------
+  w0      = wp0[2].w;
+  o0      = wp0[2].o;
+  offset  = wp0[2].offset;
+  shift   = wp0[2].shift + shiftNum;
+  round   = (1<<(shift-1));
+  w1      = wp1[2].w;
+  o1      = wp1[2].o;
+
+  pDstV[iPosY*iDstStride+iPosX] = weightBidir(w0,pSrcV0[iPosY*iSrc0Stride+iPosX], w1,pSrcV1[iPosY*iSrc1Stride+iPosX], round, shift, offset);
+}
+
+Void TComWeightPrediction::addWeightUni_DBMP( TComYuv* pcYuvSrc0, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, TComYuv* rpcYuvDst )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = rpcYuvDst->getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = rpcYuvDst->getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = rpcYuvDst->getCrAddr  ( iPartUnitIdx );
+  
+  // Luma : --------------------------------------------
+  Int w0      = wp0[0].w;
+  Int offset  = wp0[0].offset;
+  Int shift   = wp0[0].shift;
+  Int round   = wp0[0].round;
+
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iDstStride  = rpcYuvDst->getStride();
+  
+  pDstY[iPosY*iDstStride+iPosX] = weightUnidir(w0,pSrcY0[iPosY*iSrc0Stride+iPosX], round, shift, offset);
+   
+  // Chromas : --------------------------------------------
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iDstStride  = rpcYuvDst->getCStride();
+  
+  iPosX = iPosX>>1;
+  iPosY = iPosY>>1;
+
+  // Chroma U : --------------------------------------------
+  w0      = wp0[1].w;
+  offset  = wp0[1].offset;
+  shift   = wp0[1].shift;
+  round   = wp0[1].round;
+  
+  pDstU[iPosY*iDstStride+iPosX] = weightUnidir(w0,pSrcU0[iPosY*iSrc0Stride+iPosX], round, shift, offset);
+
+  // Chroma V : --------------------------------------------
+  w0      = wp0[2].w;
+  offset  = wp0[2].offset;
+  shift   = wp0[2].shift;
+  round   = wp0[2].round;
+
+  pDstV[iPosY*iDstStride+iPosX] = weightUnidir(w0,pSrcV0[iPosY*iSrc0Stride+iPosX], round, shift, offset);
+}
+
+Void TComWeightPrediction::xWeightedPredictionUni_DBMP( TComDataCU* pcCU, TComYuv* pcYuvSrc, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx )
+{ 
+  wpScalingParam  *pwp, *pwpTmp;
+  Int             iRefIdx   = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           assert (iRefIdx >= 0);
+  Int             ibdi = (g_uiBitDepth+g_uiBitIncrement);
+
+  if ( eRefPicList == REF_PIC_LIST_0 )
+  {
+    getWpScaling(pcCU, iRefIdx, -1, pwp, pwpTmp, ibdi);
+  }
+  else
+  {
+    getWpScaling(pcCU, -1, iRefIdx, pwpTmp, pwp, ibdi);
+  }
+  addWeightUni_DBMP( pcYuvSrc, uiPartAddr, iPosX, iPosY, pwp, rpcYuvPred );
+}
+
+Void TComWeightPrediction::xWeightedPredictionBi_DBMP( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iPosX, Int iPosY, TComYuv* rpcYuvDst )
+{
+  wpScalingParam  *pwp0, *pwp1;
+  TComPPS         *pps = pcCU->getSlice()->getPPS();
+
+  if ( !pps->getUseWP() ) {
+    printf("TComWeightPrediction::xWeightedPredictionBi():\tassert failed: useWP is false.\n");
+    exit(0);
+  }
+
+  Int ibdi = (g_uiBitDepth+g_uiBitIncrement);
+  getWpScaling(pcCU, iRefIdx0, iRefIdx1, pwp0, pwp1, ibdi);
+
+  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
+  {
+    addWeightBi_DBMP(pcYuvSrc0, pcYuvSrc1, uiPartIdx, iPosX, iPosY, pwp0, pwp1, rpcYuvDst );
+  }
+  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
+  {
+    addWeightUni_DBMP( pcYuvSrc0, uiPartIdx, iPosX, iPosY, pwp0, rpcYuvDst );
+  }
+  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
+  {
+    addWeightUni_DBMP( pcYuvSrc1, uiPartIdx, iPosX, iPosY, pwp1, rpcYuvDst );
+  }
+  else
+    assert (0);
+
+}
+#endif
+
 #endif  // WEIGHT_PRED
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComWeightPrediction.h	(revision 28)
@@ -37,4 +37,12 @@
   Void  xWeightedPredictionBi( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst );
 
+#if POZNAN_DBMP
+  Void  addWeightBi_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound=true );
+  Void  addWeightUni_DBMP( TComYuv* pcYuvSrc0, UInt iPartUnitIdx, UInt iPosX, Int iPosY, wpScalingParam *wp0, TComYuv* rpcYuvDst );
+
+  Void  xWeightedPredictionUni_DBMP( TComDataCU* pcCU, TComYuv* pcYuvSrc, UInt uiPartAddr, Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx );
+  Void  xWeightedPredictionBi_DBMP( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iPosX, Int iPosY, TComYuv* rpcYuvDst );
+#endif
+
   __inline  Pel   xClip  ( Int x );
   __inline  Pel   weightBidir( Int w0, Pel P0, Int w1, Pel P1, Int round, Int shift, Int offset);
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComYuv.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComYuv.cpp	(revision 28)
@@ -387,4 +387,84 @@
 }
 
+#if POZNAN_DBMP
+
+Void TComYuv::copyPartToPartYuv_DBMP   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY )
+{
+  copyPartToPartLuma_DBMP   (pcYuvDst, uiPartIdx, uiPosX, uiPosY );
+  copyPartToPartChroma_DBMP (pcYuvDst, uiPartIdx, uiPosX>>1, uiPosY>>1 );
+}
+
+Void TComYuv::copyPartToPartLuma_DBMP  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY )
+{
+  Pel* pSrc =           getLumaAddr(uiPartIdx);
+  Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx);
+  if( pSrc == pDst )
+  {
+    //th not a good idea
+    //th best would be to fix the caller 
+    return ;
+  }
+  
+  UInt  iSrcStride = getStride();
+  UInt  iDstStride = pcYuvDst->getStride();
+
+  ::memcpy( pDst+uiPosY*iDstStride+uiPosX, pSrc+uiPosY*iSrcStride+uiPosX, sizeof(Pel) );
+}
+
+Void TComYuv::copyPartToPartChroma_DBMP( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY )
+{
+  Pel*  pSrcU =           getCbAddr(uiPartIdx);
+  Pel*  pSrcV =           getCrAddr(uiPartIdx);
+  Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
+  Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
+  
+  if( getCbAddr() == NULL || getCrAddr() == NULL || pcYuvDst->getCbAddr() == NULL || pcYuvDst->getCrAddr() == NULL ) //KUBA CHROMA
+  {
+    return ;
+  }
+  if( pSrcU == pDstU && pSrcV == pDstV)
+  {
+    //th not a good idea
+    //th best would be to fix the caller 
+    return ;
+  }
+  
+  UInt   iSrcStride = getCStride();
+  UInt   iDstStride = pcYuvDst->getCStride();
+
+  ::memcpy( pDstU+uiPosY*iDstStride+uiPosX, pSrcU+uiPosY*iSrcStride+uiPosX, sizeof(Pel) );
+  ::memcpy( pDstV+uiPosY*iDstStride+uiPosX, pSrcV+uiPosY*iSrcStride+uiPosX, sizeof(Pel) );
+}
+
+#if DEPTH_MAP_GENERATION
+Void TComYuv::copyPartToPartYuvPdm_DBMP   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  copyPartToPartLumaPdm_DBMP   (pcYuvDst, uiPartIdx, uiPosX, uiPosY, uiSubSampExpX, uiSubSampExpY );
+}
+
+Void TComYuv::copyPartToPartLumaPdm_DBMP  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpX;
+  UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpY;
+  Pel* pSrc   = getLumaAddr(uiPartIdx);
+  Pel* pDst   = pcYuvDst->getLumaAddr() + uiBlkY * pcYuvDst->getStride() + uiBlkX;
+  
+  if( pSrc == pDst )
+  {
+    //th not a good idea
+    //th best would be to fix the caller 
+    return ;
+  }
+  
+  UInt  iSrcStride = getStride();
+  UInt  iDstStride = pcYuvDst->getStride();
+
+  ::memcpy( pDst+uiPosY*iDstStride+uiPosX, pSrc+uiPosY*iSrcStride+uiPosX, sizeof(Pel) );
+}
+
+#endif
+
+#endif
+
 Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
 {
@@ -862,4 +942,122 @@
 #endif
 
+#if POZNAN_DBMP
+
+#ifdef ROUNDING_CONTROL_BIPRED
+
+Void TComYuv::addAvg_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, Bool bRound )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = getCrAddr  ( iPartUnitIdx );
+  
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = getStride();
+
+#if HIGH_ACCURACY_BI
+  Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement);
+  Int offset = (1<<(shiftNum - 1));
+  
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = Clip(((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + offset) >> shiftNum );
+   
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+  
+#else
+
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = ((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + bRound) >> 1;
+   
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+  
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + bRound) >> 1;
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + bRound) >> 1;
+#endif
+}
+
+#endif
+
+Void TComYuv::addAvg_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY )
+{
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
+  Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
+  
+  Pel* pDstY   = getLumaAddr( iPartUnitIdx );
+  Pel* pDstU   = getCbAddr  ( iPartUnitIdx );
+  Pel* pDstV   = getCrAddr  ( iPartUnitIdx );
+  
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = getStride();
+#if HIGH_ACCURACY_BI
+  Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement);
+  Int offset = (1<<(shiftNum - 1));
+  
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = Clip(((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + offset) >> shiftNum );
+
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+  
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum );
+
+#else  
+  //Luma
+  (pDstY+iPosY*iDstStride)[iPosX] = ((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + 1) >> 1;
+   
+  iSrc0Stride = pcYuvSrc0->getCStride();
+  iSrc1Stride = pcYuvSrc1->getCStride();
+  iDstStride  = getCStride();
+  
+  //Chroma
+  (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + 1) >> 1;
+  (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + 1) >> 1;
+#endif
+}
+
+#if DEPTH_MAP_GENERATION
+Void TComYuv::addAvgPdm_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY )
+{
+  UInt uiBlkX  = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX;
+  UInt uiBlkY  = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY;
+  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
+  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
+  Pel* pDstY   = getLumaAddr() + uiBlkY * getStride() + uiBlkX;
+  
+  UInt  iSrc0Stride = pcYuvSrc0->getStride();
+  UInt  iSrc1Stride = pcYuvSrc1->getStride();
+  UInt  iDstStride  = getStride();
+
+  pDstY[iPosY*iDstStride+iPosX] = (pSrcY0[iPosY*iSrc0Stride+iPosX] + pSrcY1[iPosY*iSrc1Stride+iPosX] + 1) >> 1;
+}
+#endif
+
+#endif
 
 Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight )
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComYuv.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TComYuv.h	(revision 28)
@@ -118,4 +118,14 @@
 #endif
   
+#if POZNAN_DBMP
+  Void	  copyPartToPartYuv_DBMP	( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );  
+  Void    copyPartToPartLuma_DBMP   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
+  Void    copyPartToPartChroma_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY );
+#if DEPTH_MAP_GENERATION
+  Void    copyPartToPartYuvPdm_DBMP  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY );
+  Void    copyPartToPartLumaPdm_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY );
+#endif
+#endif
+  
   // ------------------------------------------------------------------------------------------------------------------
   //  Algebraic operation for YUV buffer
@@ -143,4 +153,14 @@
 #endif
 
+#if POZNAN_DBMP
+#ifdef ROUNDING_CONTROL_BIPRED
+  Void    addAvg_DBMP            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, Bool bRound );
+#endif
+  Void    addAvg_DBMP            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY );
+#if DEPTH_MAP_GENERATION
+  Void    addAvgPdm_DBMP         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY );
+#endif
+#endif
+
   //   Remove High frequency
   Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight );
Index: /branches/0.3-poznan-univ/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibCommon/TypeDef.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibCommon/TypeDef.h	(revision 28)
@@ -65,5 +65,67 @@
 //<<<<< HHI 3DV tools <<<<<
 
-
+//<<<<< Poznan 3DV tools <<<<<<
+#define POZNAN_CU_SKIP              1 //Poznan Cu Skip
+#define POZNAN_CU_SYNTH             1 //Poznan Cu Synth
+
+#define POZNAN_AVAIL_MAP            1 //Creates Availibity buffers in all needed classes
+
+#define POZNAN_SYNTH_VIEW           1 //Creates view synthesis buffers in all needed classes
+#define POZNAN_SYNTH_DEPTH          1
+
+#define POZNAN_SYNTH                1 //Creates aligned synthesis classes in encoder and decoder
+
+#define POZNAN_ENCODE_ONLY_DISOCCLUDED_CU          1 //Poznan CU Skip
+#define POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS     1 //Fill not sended CUs with synthesized data
+
+#define POZNAN_VSO_FIX              0
+
+#define POZNAN_CU_SKIP_PSNR         1 //Poznan Cu Skip Display psnr of the codded CUs only
+
+#define POZNAN_NONLINEAR_DEPTH              1	 /// Non-linear depth processing (Maciej Kurc)
+#define POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE 1	 /// Send DepthPower as byte instead of float
+
+#if POZNAN_SYNTH 
+#define POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH 1 /// Increase QP for texture CUs that are in the background (according to proper depth map). This QP change is not encoded in a bitstream
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH     
+ #define POZNAN_TEXTURE_TU_DELTA_QP_NOT_IN_BASE_VIEW 1     /// should not be disabled in current software version - no depth synthesis map is available for base view anyway  
+ #define POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_CU_ROW 1    /// increase of QP param for top and bottom LCU row in frame 
+ #define POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 0 /// used for optimization of function calculating dQP from depth block max value. Standard values set if disabled. If enabled params are set in cfg file for encoder (no decoder is supported in that case).
+  #if !POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
+    #define POZNAN_TEXTURE_TU_DELTA_QP_OFFSET (-2.6)
+    #define POZNAN_TEXTURE_TU_DELTA_QP_MUL (1)
+    #define POZNAN_TEXTURE_TU_DELTA_QP_TOP_BOTTOM_ROW_VAL (0)
+  #endif
+#endif
+
+#define POZNAN_MP                                  1    /// Depth-Based Multiview Prediction of CU parameters
+#if POZNAN_MP
+
+#define POZNAN_MP_USE_DEPTH_MAP_GENERATION 0 // determines if DEPTH_MAP_GENERATION is used for calculating corresponding pixel position in PUT multiview prediction (POZNAN_MP): 
+										                                                        //			POZNAN_MP_USE_DEPTH_MAP_GENERATION=1 - use DEPTH_MAP_GENERATION, 
+										                                                        //			POZNAN_MP_USE_DEPTH_MAP_GENERATION=0 - use reconstructed depth maps from neighboring views
+
+#define POZNAN_MP_FILL                             1    // Depth-Based Multiview Prediction of CU parameters with fill option for occluded areas
+#if POZNAN_MP_FILL
+#define POZNAN_MP_FILL_TYPE                        0    // Variant of fill algorithm used for occluded areas (0 - smaller disparity, 1 - larger disparity)
+#endif
+
+// ---------------------------------------
+
+#define POZNAN_DBMP                                1    // Depth Based Motion Prediction prediction for MERGE
+#if POZNAN_DBMP
+#define POZNAN_DBMP_USE_FOR_TEXTURE                  1    //use Depth Based Motion Prediction in texture pictures (0 - no, 1 -yes)
+#define POZNAN_DBMP_USE_FOR_DEPTH                  1    // use Depth Based Motion Prediction in depth pictures (0 - no, 1 -yes)
+
+#define POZNAN_DBMP_CALC_PRED_DATA 	        1    // Depth Based Motion Prediction motion data used for prediction in other CUs is calculated based on all CU points (otherwise motion data for none-MP points is used for prediction)
+#define POZNAN_DBMP_COMPRESS_ME_DATA	        0    // Depth Based Motion Prediction derives representative motion data from reference CUs even if they are DBMP-based predicted (otherwise motion data is derived with per-point resolution for DBMP-based predicted reference CUs)
+#define POZNAN_DBMP_USE_IN_NONANCHOR_PIC_ONLY     	1    // determines if Depth Based Motion Prediction is used in non-anchor pictures only
+#endif
+
+#endif
+
+
+//<<<<< Poznan 3DV tools <<<<<<
 
 ////////////////////////////
@@ -345,4 +407,5 @@
 typedef       unsigned long       ULong;
 typedef       double              Double;
+typedef       float               Float;
 
 // ====================================================================================================================
@@ -580,4 +643,7 @@
   MODE_INTER,           ///< inter-prediction mode
   MODE_INTRA,           ///< intra-prediction mode
+#if POZNAN_SYNTH
+  MODE_SYNTH,           ///< synth-mode
+#endif
   MODE_NONE = 15
 };
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 28)
@@ -237,5 +237,12 @@
   xReadFlag( uiCode ); pcSPS->setUseSAO       ( uiCode ? true : false );
 #endif
-
+#if POZNAN_DBMP
+	  xReadFlag( uiCode );
+	  pcSPS->setDBMP  ( uiCode );
+#endif
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+	  xReadFlag( uiCode );
+	  pcSPS->setUseCUSkip ( uiCode );
+#endif
   xReadFlag( uiCode ); // SPS base view flag
   if( uiCode )
@@ -270,4 +277,17 @@
       xReadFlag( uiCode );
       pcSPS->setUseMVI( uiCode ? true : false );
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+#if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE
+      uiCode = 0;
+      xReadCode(8, uiCode);
+      pcSPS->setDepthPower(dequantizeDepthPower(uiCode));
+#else
+      uiCode = 0;
+      xReadCode(sizeof(float)*8, uiCode); // We do not send seign
+      //uiCode &= ~0x80000000;
+      pcSPS->setDepthPower(*((float*)&uiCode));  
+#endif
+      printf("\nfDepthPower = %f", pcSPS->getDepthPower());
 #endif
     }
@@ -325,4 +345,8 @@
       pcSPS->setMultiviewResPredMode  ( uiMultiviewResPredMode );
 #endif
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      xReadFlag( uiCode );
+      pcSPS->setUseTexDqpAccordingToDepth( uiCode ? true : false );
 #endif
 #if HHI_MPI
@@ -2621,5 +2645,5 @@
 
 
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
 Void 
 TDecCavlc::parseMergeIndexMV( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
@@ -2632,4 +2656,8 @@
     uiNumCand++;
 #endif
+#if POZNAN_DBMP
+  UInt uiModIdx;
+  const Bool bDBMPAvailable = pcCU->getSlice()->getMP()->isDBMPEnabled();
+#endif
   for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ )
   {
@@ -2656,15 +2684,43 @@
     if( uiIdx > uiMviMergePos )
     {
+#if POZNAN_DBMP
+	  if(bDBMPAvailable)
+	  {
+		  if(uiIdx==POZNAN_DBMP_MERGE_POS) uiModIdx = POZNAN_DBMP_MRG_CAND;
+		  else if(uiIdx>POZNAN_DBMP_MERGE_POS) uiModIdx = uiIdx--;
+		  else uiModIdx = uiIdx;
+	  }
+	  else uiModIdx = uiIdx;
+	  if( pcCU->getNeighbourCandIdx( uiModIdx-1, uiAbsPartIdx ) != uiModIdx )
+	  {
+        ruiMergeIndex++;
+      }
+#else
       if( pcCU->getNeighbourCandIdx( uiIdx - 1, uiAbsPartIdx ) != uiIdx )
       {
         ruiMergeIndex++;
       }
+#endif
     }
     else if( uiIdx < uiMviMergePos )
 #endif
+#if POZNAN_DBMP
+	if(bDBMPAvailable)
+	{
+	  if(uiIdx==POZNAN_DBMP_MERGE_POS) uiModIdx = POZNAN_DBMP_MRG_CAND;
+	  else if(uiIdx>POZNAN_DBMP_MERGE_POS) uiModIdx = uiIdx--;
+	  else uiModIdx = uiIdx;
+	}
+	else uiModIdx = uiIdx;
+	if( pcCU->getNeighbourCandIdx( uiModIdx, uiAbsPartIdx ) != uiModIdx + 1 )
+	{
+	  ruiMergeIndex++;
+	}
+#else
     if( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) != uiIdx + 1 )
     {
       ruiMergeIndex++;
     }
+#endif
   }
 #if HHI_MPI
@@ -2676,4 +2732,11 @@
   {
     pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth );
+  }
+#endif
+#if POZNAN_DBMP
+  if(bDBMPAvailable)
+  {	  
+	if(ruiMergeIndex==POZNAN_DBMP_MERGE_POS) ruiMergeIndex = POZNAN_DBMP_MRG_CAND;
+	else if(ruiMergeIndex>POZNAN_DBMP_MERGE_POS) ruiMergeIndex--;
   }
 #endif
@@ -2691,5 +2754,5 @@
 Void TDecCavlc::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
 {
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
   if(
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -2698,4 +2761,7 @@
 #if HHI_MPI
       ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ||
+#endif
+#if	POZNAN_DBMP  
+	  ( pcCU->getSlice()->getMP()->isDBMPEnabled() ) ||
 #endif
       0
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 28)
@@ -195,5 +195,5 @@
   Void parseMergeFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
   Void parseMergeIndexMV    ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCu.cpp	(revision 28)
@@ -49,4 +49,10 @@
   m_ppcYuvReco    = NULL;
   m_ppcYuvResPred = NULL;
+#if POZNAN_AVAIL_MAP
+  m_ppcYuvAvail   = NULL;
+#endif
+#if POZNAN_SYNTH_VIEW
+  m_ppcYuvSynth   = NULL;
+#endif
   m_ppcCU         = NULL;
 }
@@ -75,4 +81,10 @@
   m_ppcYuvReco    = new TComYuv*    [m_uiMaxDepth-1];
   m_ppcYuvResPred = new TComYuv*    [m_uiMaxDepth-1];
+#if POZNAN_AVAIL_MAP
+  m_ppcYuvAvail   = new TComYuv*    [m_uiMaxDepth-1];
+#endif
+#if POZNAN_SYNTH_VIEW
+  m_ppcYuvSynth   = new TComYuv*    [m_uiMaxDepth-1];
+#endif
   m_ppcCU         = new TComDataCU* [m_uiMaxDepth-1];
   
@@ -87,4 +99,11 @@
     m_ppcYuvReco   [ui] = new TComYuv;    m_ppcYuvReco   [ui]->create( uiWidth, uiHeight );
     m_ppcYuvResPred[ui] = new TComYuv;    m_ppcYuvResPred[ui]->create( uiWidth, uiHeight );
+#if POZNAN_AVAIL_MAP
+    m_ppcYuvAvail  [ui] = new TComYuv;    m_ppcYuvAvail  [ui]->create( uiWidth, uiHeight );
+#endif
+#if POZNAN_SYNTH_VIEW
+    m_ppcYuvSynth  [ui] = new TComYuv;    m_ppcYuvSynth  [ui]->create( uiWidth, uiHeight );
+#endif
+
     m_ppcCU        [ui] = new TComDataCU; m_ppcCU        [ui]->create( uiNumPartitions, uiWidth, uiHeight, true );
   }
@@ -106,4 +125,10 @@
     m_ppcYuvReco   [ui]->destroy(); delete m_ppcYuvReco   [ui]; m_ppcYuvReco   [ui] = NULL;
     m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL;
+#if POZNAN_AVAIL_MAP
+    m_ppcYuvAvail  [ui]->destroy(); delete m_ppcYuvAvail  [ui]; m_ppcYuvAvail  [ui] = NULL;
+#endif
+#if POZNAN_SYNTH_VIEW
+    m_ppcYuvSynth  [ui]->destroy(); delete m_ppcYuvSynth  [ui]; m_ppcYuvSynth  [ui] = NULL;
+#endif
     m_ppcCU        [ui]->destroy(); delete m_ppcCU        [ui]; m_ppcCU        [ui] = NULL;
   }
@@ -112,4 +137,11 @@
   delete [] m_ppcYuvReco;    m_ppcYuvReco    = NULL;
   delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL;
+#if POZNAN_AVAIL_MAP
+  delete [] m_ppcYuvAvail;   m_ppcYuvAvail   = NULL;
+#endif
+#if POZNAN_SYNTH_VIEW
+  delete [] m_ppcYuvSynth;   m_ppcYuvSynth   = NULL;
+#endif
+
   delete [] m_ppcCU;         m_ppcCU         = NULL;
 }
@@ -184,4 +216,44 @@
 {
   TComPic* pcPic = pcCU->getPic();
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Bool bWholeCUCanBeSynthesized = false;
+  Bool bOneSubCUCanNotBeSynthesied = false;
+  Bool bSubCUCanBeSynthesized[4];
+  Bool * pbSubCUCanBeSynthesized = bSubCUCanBeSynthesized;
+  pcPic->checkSynthesisAvailability(pcCU, pcCU->getAddr(), uiAbsPartIdx, uiDepth, pbSubCUCanBeSynthesized); //KUBA SYNTH
+  Int  iSubCUCanNotBeSynthesized = 0;
+  Int  iSubCUCanBeSynthesizedCnt = 0;
+  for(Int i = 0; i < 4; i++)
+  {
+    if (!bSubCUCanBeSynthesized[i])
+    {
+      iSubCUCanNotBeSynthesized = i;
+    }
+    else
+    {
+      iSubCUCanBeSynthesizedCnt ++;
+    }
+  }
+  if(iSubCUCanBeSynthesizedCnt == 4)
+  {
+    bWholeCUCanBeSynthesized = true;
+  }
+  else if(iSubCUCanBeSynthesizedCnt == 3)
+  {
+    bOneSubCUCanNotBeSynthesied = true;
+  }
+
+  if(bWholeCUCanBeSynthesized)
+  {
+    pcCU->setPredModeSubParts( MODE_SYNTH, uiAbsPartIdx, uiDepth );
+    pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx );
+    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
+    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
+    //pcCU->setSizeSubParts( pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth, pcCU->getSlice()->getSPS()->getMaxCUHeight()>>uiDepth, uiAbsPartIdx, uiDepth );
+    return;    
+  }
+#endif
+
   UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
   UInt uiQNumParts      = uiCurNumParts>>2;
@@ -195,4 +267,11 @@
   if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
   {
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    if(bOneSubCUCanNotBeSynthesied && (uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )) // Check if CU has 3 synthesied subCU - no split flag is send in that case and CU split is assumed
+    {
+      pcCU->setDepthSubParts( uiDepth + 1, uiAbsPartIdx );
+    }
+    else 
+#endif
 #if HHI_MPI
     if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
@@ -367,4 +446,10 @@
 {
   TComPic* pcPic = pcCU->getPic();
+#if POZNAN_SYNTH_VIEW
+  if(pcPic->getPicYuvSynth())  m_ppcYuvSynth[uiDepth]->copyFromPicYuv( pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx );
+#endif
+#if POZNAN_AVAIL_MAP
+  if(pcPic->getPicYuvAvail())  m_ppcYuvAvail[uiDepth]->copyFromPicYuv( pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx );
+#endif
   
   Bool bBoundary = false;
@@ -411,4 +496,15 @@
       xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
       break;
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    case MODE_SYNTH:
+    //  break;
+#if POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS
+      m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvSynth(), pcCU->getAddr(), uiAbsPartIdx);
+#else
+      m_ppcYuvReco[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), pcCU->getAddr(), uiAbsPartIdx); //Poprawiæ
+#endif
+      //m_ppcYuvReco[uiDepth]->clear();
+      break;
+#endif
     default:
       assert(0);
@@ -485,5 +581,9 @@
     m_pcPrediction->predIntraLumaAng( pcPattern, pcCU->getLumaIntraDir(uiPartIdx), pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
     
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx) + pcCU->getQpOffsetForTextCU(uiPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
     m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
 #if INTRA_DST_TYPE_7
   m_pcTrQuant->invtransformNxN(TEXT_LUMA, pcCU->getLumaIntraDir(uiPartIdx), pResi, uiStride, pCoeff, uiWidth, uiHeight );
@@ -682,5 +782,9 @@
   }
   //===== inverse transform =====
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_pcTrQuant->setQPforQuant( pcCU->getQP(0) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
   m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
 #if INTRA_DST_TYPE_7
   m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight );
@@ -789,5 +893,9 @@
 
   //===== inverse transform =====
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
+#else
   m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText );
+#endif
 #if INTRA_DST_TYPE_7 
   m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight );
@@ -965,9 +1073,18 @@
   piCoeff = pcCU->getCoeffY();
   pResi = m_ppcYuvResi[uiDepth]->getLumaAddr();
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Int QPoffset = pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false);
+  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(uiAbsPartIdx) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
   
   // Cb and Cr
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ) + QPoffset, !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
   
   uiWidth  >>= 1;
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCu.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecCu.h	(revision 28)
@@ -61,4 +61,10 @@
   TComYuv**           m_ppcYuvReco;       ///< array of prediction & reconstruction buffer
   TComYuv**           m_ppcYuvResPred;    ///< residual prediction buffer
+#if POZNAN_AVAIL_MAP
+  TComYuv**           m_ppcYuvAvail;      ///< array of available map buffer
+#endif
+#if POZNAN_SYNTH_VIEW
+  TComYuv**           m_ppcYuvSynth;      ///< array of synth buffer
+#endif
   TComDataCU**        m_ppcCU;            ///< CU data array
   
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 28)
@@ -430,4 +430,15 @@
   pcCU->setInterDirSubParts( puhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, uiPartIdx, uiDepth );
 
+#if POZNAN_DBMP_CALC_PRED_DATA
+  Int ref_idx0_DBMP,ref_idx1_DBMP;
+  TComMv cMv0_DBMP( 0, 0 ),cMv1_DBMP( 0, 0 );
+  if(uiMergeIndex==POZNAN_DBMP_MRG_CAND)
+  {	
+    pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+    pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );	
+    pcCU->getSlice()->getMP()->calcDBMPPredData(pcCU, uiAbsPartIdx, ref_idx0_DBMP, cMv0_DBMP, ref_idx1_DBMP, cMv1_DBMP);
+  }
+#endif
+
   TComMv cTmpMv( 0, 0 );
   if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0  ) //if ( ref. frame list0 has at least 1 entry )
@@ -436,4 +447,9 @@
     pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth);
     pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+#if POZNAN_DBMP_CALC_PRED_DATA
+    if(uiMergeIndex==POZNAN_DBMP_MRG_CAND) 
+       pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMv0_DBMP, ref_idx0_DBMP, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+    else
+#endif
     pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
 
@@ -444,4 +460,9 @@
     pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth);
     pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+#if POZNAN_DBMP_CALC_PRED_DATA
+    if(uiMergeIndex==POZNAN_DBMP_MRG_CAND)
+       pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMv1_DBMP, ref_idx1_DBMP, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
+    else
+#endif
     pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth );
   }
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecGop.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecGop.cpp	(revision 28)
@@ -199,4 +199,14 @@
 #endif
 
+#if POZNAN_MP
+	if( uiStartCUAddr == 0 )
+    {
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	  pcSlice->getMP()->setDepthMapGenerator(m_pcDepthMapGenerator);
+#endif
+      pcSlice->getMP()->pairMultiview(rpcPic);
+	}
+#endif
+
     // decode slice
     m_pcSliceDecoder->decompressSlice(pcBitstream, rpcPic);
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 28)
@@ -579,5 +579,5 @@
 
 
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
 Void TDecSbac::parseMergeIndexMV( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -585,4 +585,8 @@
   const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
   const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : MRG_MAX_NUM_CANDS;
+#endif
+#if POZNAN_DBMP
+  const Bool bDBMPAvailable = pcCU->getSlice()->getMP()->isDBMPEnabled();
+  Bool bDBMPModifyMergeIdx = true;
 #endif
   //--- set number of candidates and availability ---
@@ -611,4 +615,32 @@
     }
   }
+
+#if POZNAN_DBMP
+  if(bDBMPAvailable)
+  {
+    UInt uiDBMPMergePos = POZNAN_DBMP_MERGE_POS;
+#if HHI_MPI
+	if(bMVIAvailable && uiDBMPMergePos>=uiMviMergePos) uiDBMPMergePos++;
+#endif
+	for( Int iIdx = MRG_MAX_NUM_CANDS-2; iIdx >= (Int)uiDBMPMergePos; iIdx-- )
+	{
+		Int iWrIdx = iIdx+1;
+#if HHI_MPI
+		if(bMVIAvailable) 
+		{
+			if(iIdx==(Int)uiMviMergePos) continue;
+			if(iWrIdx==(Int)uiMviMergePos) iWrIdx++;
+		}
+#endif
+		if(iWrIdx>=MRG_MAX_NUM_CANDS) continue;
+
+		abAvailable[ iWrIdx ] = abAvailable[ iIdx ];
+	}
+	abAvailable[ uiDBMPMergePos ] = ( pcCU->getNeighbourCandIdx( POZNAN_DBMP_MRG_CAND, uiAbsPartIdx ) == POZNAN_DBMP_MRG_CAND + 1 );
+	
+	uiNumCand = 0; for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) if(abAvailable[ uiIdx ]) uiNumCand++;
+  }
+#endif
+
   AOF( uiNumCand > 1 );
 
@@ -665,4 +697,15 @@
   {
     pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth );
+#if POZNAN_DBMP
+	bDBMPModifyMergeIdx = false;
+#endif
+  }
+#endif
+
+#if POZNAN_DBMP
+  if(bDBMPAvailable && bDBMPModifyMergeIdx)
+  {
+	if(ruiMergeIndex==POZNAN_DBMP_MERGE_POS) ruiMergeIndex = POZNAN_DBMP_MRG_CAND;
+	else if(ruiMergeIndex>POZNAN_DBMP_MERGE_POS) ruiMergeIndex--;
   }
 #endif
@@ -694,5 +737,5 @@
 Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
 {
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
   if(
 #if HHI_INTER_VIEW_MOTION_PRED
@@ -701,4 +744,7 @@
 #if HHI_MPI
       ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ||
+#endif
+#if	POZNAN_DBMP  
+	  ( pcCU->getSlice()->getMP()->isDBMPEnabled() ) ||
 #endif
       0
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecSbac.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecSbac.h	(revision 28)
@@ -144,5 +144,5 @@
   Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
   Void parseMergeIndexMV  ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp	(revision 28)
@@ -53,4 +53,10 @@
     m_aaiCodedScale       [ uiId ] = new Int [ MAX_NUMBER_VIEWS ];
   }
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+  xCreateLUTs   ( (UInt)MAX_NUMBER_VIEWS, (UInt)MAX_NUMBER_VIEWS,  m_adBaseViewShiftLUT,  m_aiBaseViewShiftLUT);
+
+  m_iLog2Precision   = LOG2_DISP_PREC_LUT;
+  m_uiBitDepthForLUT = 8; //fixed
+#endif
 }
 
@@ -66,4 +72,9 @@
   delete [] m_aiViewOrderIndex;
   delete [] m_aiViewReceived;
+
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+  xDeleteArray( m_adBaseViewShiftLUT,        MAX_NUMBER_VIEWS, MAX_NUMBER_VIEWS,  2 );
+  xDeleteArray( m_aiBaseViewShiftLUT,        MAX_NUMBER_VIEWS, MAX_NUMBER_VIEWS,  2 );
+#endif
 }
 
@@ -78,5 +89,124 @@
   m_iLastPOC                = -1;
   m_uiMaxViewId             = 0;
-}
+#if POZNAN_NONLINEAR_DEPTH
+  m_fDepthPower             = 1.0;
+#endif
+}
+
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+Void
+CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT)
+{
+  //AOF( m_uiBitDepthForLUT == 8 );
+  //AOF(radLUT == NULL && raiLUT == NULL );
+
+  uiNumberSourceViews = Max( 1, uiNumberSourceViews );
+  uiNumberTargetViews = Max( 1, uiNumberTargetViews );
+
+  radLUT         = new Double***[ uiNumberSourceViews ];
+  raiLUT         = new Int   ***[ uiNumberSourceViews ];
+
+  for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
+  {
+    radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
+    raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
+
+    for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
+    {
+      radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
+      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
+      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
+
+      raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
+      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
+      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
+    }
+  }
+}
+
+Void 
+CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
+{
+  Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
+  Int     iLog2DivChroma = iLog2DivLuma + 1;
+
+  iOffset <<= m_uiBitDepthForLUT;
+
+  Double dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
+  Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
+
+  // offsets including rounding offsets
+  Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
+  Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
+
+#if POZNAN_NONLINEAR_DEPTH
+  TComNonlinearDepthBackward cNonlinearDepthBwd(m_fDepthPower, (POZNAN_LUT_INCREASED_PRECISION) ? g_uiBitIncrement : 0, (POZNAN_LUT_INCREASED_PRECISION) ? g_uiBitIncrement : 0);
+#endif
+
+  for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
+  {
+    Double  dDepthValue = (Double)uiDepthValue;
+    Int64   iDepthValue = (Int64)uiDepthValue;
+#if POZNAN_NONLINEAR_DEPTH
+    dDepthValue = cNonlinearDepthBwd(dDepthValue);
+    iDepthValue = (Int64)(dDepthValue+0.5);
+#endif
+#if POZNAN_LUT_INCREASED_PRECISION
+    dDepthValue /= (1<<g_uiBitIncrement);
+#endif
+
+    // real-valued look-up tables
+    Double  dShiftLuma      = ( dDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
+    Double  dShiftChroma    = dShiftLuma / 2;
+    radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
+    radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
+
+    // integer-valued look-up tables
+    Int64   iTempScale      = iDepthValue * iScale;
+#if POZNAN_LUT_INCREASED_PRECISION
+    iTempScale >>= g_uiBitIncrement;
+#endif
+    Int64   iTestScale      = ( iTempScale + iOffset       );   // for checking accuracy of camera parameters
+    Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
+    Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
+    raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
+    raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
+
+    // maximum deviation
+    //dMaxDispDev     = Max( dMaxDispDev,    fabs( Double( (Int) iTestScale   ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) );
+    //dMaxRndDispDvL  = Max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) );
+    //dMaxRndDispDvC  = Max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) );
+  }
+
+  radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
+  radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
+  raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
+  raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
+}
+
+Bool
+CamParsCollector::getNearestBaseView( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft)
+{
+  /*
+  riNearestViewIdx = 0;
+
+  Bool bDecencdingVN = ( m_aiSortedBaseViews.size() >= 2 && m_aiSortedBaseViews[ 0 ] > m_aiSortedBaseViews[ 1 ] );
+  Int  iFactor       = ( bDecencdingVN ? -1 : 1 );
+
+  if( ( m_aiBaseId2SortedId[iSynthViewIdx] - m_aiBaseId2SortedId[riNearestViewIdx] ) * iFactor  <= 0 )
+  {
+    rbRenderFromLeft = true;
+  }
+  else
+  {
+    rbRenderFromLeft = false;
+  }
+
+  riRelDistToLeft = 128; //Not used for now;
+//*/
+  return true;
+}
+
+#endif
 
 Void
@@ -102,5 +232,14 @@
   if ( pcSlice->getSPS()->isDepth  () )
   {
+#if POZNAN_NONLINEAR_DEPTH
+    m_fDepthPower = pcSlice->getSPS()->getDepthPower();
+#endif
     return;
+  }
+  else
+  {
+#if POZNAN_NONLINEAR_DEPTH
+    pcSlice->getSPS()->setDepthPower(m_fDepthPower); // OLGIERD: ToDo - QP-Tex should not use getDepthPower() from texture SPS.
+#endif
   }
   Bool  bFirstAU          = ( pcSlice->getPOC()               == 0 );
@@ -161,4 +300,8 @@
         m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
         m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+        xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
+        xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
+#endif
       }
       else
@@ -168,4 +311,8 @@
         m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ];
         m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ];
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+        xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
+        xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
+#endif
       }
     }
@@ -182,4 +329,8 @@
         m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
         m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+        xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
+        xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
+#endif
       }
     }
@@ -269,4 +420,7 @@
   m_bFirstSliceInSequence   = true;
   m_pcCamParsCollector = 0;
+#if POZNAN_MP
+  m_pcMP = NULL;
+#endif
 }
 
@@ -299,4 +453,8 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   m_cResidualGenerator.destroy();
+#endif
+
+#if POZNAN_MP
+  m_pcMP = NULL;
 #endif
 }
@@ -336,4 +494,8 @@
   m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
 #endif
+
+#if POZNAN_MP
+  m_pcMP = pcTAppDecTop->getMP();
+#endif
 }
 
@@ -462,4 +624,13 @@
 #if HHI_INTERVIEW_SKIP
     pcPic->removeUsedPelsMapBuffer();
+#endif
+#if POZNAN_AVAIL_MAP
+    pcPic->removeAvailabilityBuffer();
+#endif
+#if POZNAN_SYNTH_VIEW
+    pcPic->removeSynthesisBuffer();
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    pcPic->removeSynthesisDepthBuffer();
 #endif
   }
@@ -549,4 +720,12 @@
       else
       {
+#if POZNAN_NONLINEAR_DEPTH
+        // For texture complete depth power information. Depth power is sended, for example, for base view depth map and it should be available prior non-base texture decoding
+        if(!cTempSPS.isDepth() && cTempSPS.getViewId())
+        {
+          Float fDepthPower = getDecTop()->getPicFromView( 0, pcPic->getPOC(), true )->getSPS()->getDepthPower();
+          cTempSPS.setDepthPower(fDepthPower);
+        }
+#endif
         cComSPS = cTempSPS;
         return false;
@@ -563,4 +742,12 @@
       }
       m_uiValidPS |= 1;
+
+#if POZNAN_MP
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+      m_pcMP->init( m_cSPS.getHeight(), m_cSPS.getWidth() );
+#else
+      m_pcMP->init( m_cSPS.getHeight(), m_cSPS.getWidth(), m_pcCamParsCollector->getBaseViewShiftLUTI());
+#endif 
+#endif 
 
       return false;
@@ -686,4 +873,8 @@
       m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx);
       pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
+
+#if POZNAN_MP
+	  pcSlice->setMP(m_pcMP);
+#endif
 
       if (bNextSlice)
@@ -744,6 +935,40 @@
 #endif
 
+#if POZNAN_SYNTH
+      if( m_pcCamParsCollector)
+      {
+        m_pcCamParsCollector->setSlice( pcSlice );
+      }
+      //if(!getIsDepth())
+      if(pcSlice->getSPS()->getUseCUSkip())
+      {
+        getDecTop()->storeSynthPicsInBuffer(pcSlice->getViewIdx(),pcSlice->getSPS()->getViewOrderIdx(),pcSlice->getPOC(),getIsDepth());
+      }
+#endif
+
+      //*
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      if(!getIsDepth() && pcSlice->getSPS()->getUseTexDqpAccordingToDepth())
+      {
+        getDecTop()->storeDepthSynthPicsInBuffer(pcSlice->getViewIdx(),pcSlice->getSPS()->getViewOrderIdx(),pcSlice->getPOC());
+      }
+#endif
+      //*/
+
+#if POZNAN_MP 
+	std::vector<TComPic*> apcSpatDataRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), m_cSPS.isDepth() );
+	pcSlice->getMP()->setRefPicsList(&apcSpatDataRefPics);  
+#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	std::vector<TComPic*> apcSpatDepthRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), true );
+	pcSlice->getMP()->setDepthRefPicsList(&apcSpatDepthRefPics);
+#endif
+#endif
+
       //  Decode a picture
       m_cGopDecoder.decompressGop ( bEos, pcBitstream, pcPic, false );
+
+#if POZNAN_MP
+	  //pcSlice->getMP()->disable();
+#endif
 
       if( m_pcCamParsCollector )
Index: /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecTop.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecTop.h	(revision 28)
@@ -55,4 +55,8 @@
 #include "TDecCAVLC.h"
 
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif
+
 // ====================================================================================================================
 // Class definition
@@ -71,4 +75,13 @@
   Void  uninit      ();
   Void  setSlice    ( TComSlice* pcSlice );
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+  Double****          getBaseViewShiftLUTD      ()  { return m_adBaseViewShiftLUT;   }
+  Int****             getBaseViewShiftLUTI      ()  { return m_aiBaseViewShiftLUT;   }
+
+  Int**               getBaseViewOffsetI        ()  { return m_aaiCodedOffset;   }
+  Int**               getBaseViewScaleI         ()  { return m_aaiCodedScale;   }
+
+  Bool                getNearestBaseView        ( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft);
+#endif
 
 private:
@@ -89,5 +102,86 @@
   Int     m_iLastPOC;
   UInt    m_uiMaxViewId;
+
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+
+  UInt    m_uiBitDepthForLUT;
+  UInt    m_iLog2Precision;
+  UInt    m_uiInputBitDepth;
+
+  // look-up tables
+  Double****          m_adBaseViewShiftLUT;										///< Disparity LUT
+  Int****             m_aiBaseViewShiftLUT;									  ///< Disparity LUT
+
+  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
+  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
+
+  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
+  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
+  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+  Float               m_fDepthPower;
+#endif
+
+
 };
+
+#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
+  template <class T>
+Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
+{
+  if( rpt )
+  {
+    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
+    {
+      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
+      {
+        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
+        {
+          delete[] rpt[ uiK ][ uiL ][ uiM ];
+        }
+        delete[] rpt[ uiK ][ uiL ];
+      }
+      delete[] rpt[ uiK ];
+    }
+    delete[] rpt;
+  }
+  rpt = NULL;
+};
+
+
+template <class T>
+Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
+{
+  if( rpt )
+  {
+    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
+    {
+      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
+      {
+        delete[] rpt[ uiK ][ uiL ];
+      }
+      delete[] rpt[ uiK ];
+    }
+    delete[] rpt;
+  }
+  rpt = NULL;
+};
+
+
+template <class T>
+Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
+{
+  if( rpt )
+  {
+    for( UInt uiK = 0; uiK < uiSize; uiK++ )
+    {
+      delete[] rpt[ uiK ];
+    }
+    delete[] rpt;
+  }
+  rpt = NULL;
+};
+#endif
 
 
@@ -138,4 +232,8 @@
 #endif
 
+#if POZNAN_MP
+  TComMP*				  m_pcMP;
+#endif
+
   Bool                    m_bIsDepth;
   Int                     m_iViewIdx;
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 28)
@@ -326,4 +326,10 @@
   xWriteFlag( pcSPS->getUseSAO() ? 1 : 0);
 #endif
+#if POZNAN_DBMP
+	  xWriteFlag( pcSPS->getDBMP() );
+#endif
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+	  xWriteFlag( pcSPS->getUseCUSkip() );
+#endif
 
   if( pcSPS->getViewId() || pcSPS->isDepth() )
@@ -340,4 +346,16 @@
 #if HHI_MPI
       xWriteFlag( pcSPS->getUseMVI() ? 1 : 0 );
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+      // Depth power coefficient
+#if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE
+      UInt  uiCode = quantizeDepthPower(pcSPS->getDepthPower());  
+      xWriteCode(uiCode, 8); 
+#else
+      float fCode  = pcSPS->getDepthPower();
+      UInt  uiCode = *((UInt*)&fCode);
+      //uiCode &= ~0x80000000;
+      xWriteCode(uiCode, sizeof(float)*8); // we do not send sign?;
+#endif
 #endif
     }
@@ -377,4 +395,7 @@
       }
 #endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      xWriteFlag  ( pcSPS->getUseTexDqpAccordingToDepth() ? 1 : 0 );
+#endif
     }
   }
@@ -727,5 +748,5 @@
 
 
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
 Void 
 TEncCavlc::codeMergeIndexMV( TComDataCU* pcCU, UInt uiAbsPartIdx )
@@ -733,4 +754,14 @@
   UInt uiNumCand  = 0;
   UInt uiMergeIdx = pcCU->getMergeIndex( uiAbsPartIdx );
+
+#if POZNAN_DBMP
+  UInt uiModIdx;
+  const Bool bDBMPAvailable = pcCU->getSlice()->getMP()->isDBMPEnabled();
+  if(bDBMPAvailable)
+  {	  
+	  if(uiMergeIdx==POZNAN_DBMP_MRG_CAND) uiMergeIdx = POZNAN_DBMP_MERGE_POS;
+	  else if(uiMergeIdx>=POZNAN_DBMP_MERGE_POS) uiMergeIdx++;
+  }
+#endif
 #if HHI_MPI
   const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
@@ -750,4 +781,21 @@
     if( uiIdx < uiMviMergePos )
     {
+#if POZNAN_DBMP
+	  if(bDBMPAvailable)
+	  {
+		  if(uiIdx==POZNAN_DBMP_MERGE_POS) uiModIdx = POZNAN_DBMP_MRG_CAND;
+		  else if(uiIdx>POZNAN_DBMP_MERGE_POS) uiModIdx = uiIdx--;
+		  else uiModIdx = uiIdx;
+	  }
+	  else uiModIdx = uiIdx;
+	  if( pcCU->getNeighbourCandIdx( uiModIdx, uiAbsPartIdx ) == uiModIdx + 1 )
+	  {
+        uiNumCand++;
+      }
+      else if( uiIdx < uiMergeIdx )
+      {
+        uiUnaryIdx--;
+      }
+#else
       if( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) == uiIdx + 1 )
       {
@@ -758,7 +806,25 @@
         uiUnaryIdx--;
       }
+#endif
     }
     else if( uiIdx > uiMviMergePos )
     {
+#if POZNAN_DBMP
+	  if(bDBMPAvailable)
+	  {
+		  if(uiIdx==POZNAN_DBMP_MERGE_POS) uiModIdx = POZNAN_DBMP_MRG_CAND;
+		  else if(uiIdx>POZNAN_DBMP_MERGE_POS) uiModIdx = uiIdx--;
+		  else uiModIdx = uiIdx;
+	  }
+	  else uiModIdx = uiIdx;
+	  if( pcCU->getNeighbourCandIdx( uiModIdx-1, uiAbsPartIdx ) == uiModIdx )
+	  {
+        uiNumCand++;
+      }
+      else if( uiIdx < uiMergeIdx )
+      {
+        uiUnaryIdx--;
+      }
+#else
       if( pcCU->getNeighbourCandIdx( uiIdx - 1, uiAbsPartIdx ) == uiIdx )
       {
@@ -769,4 +835,5 @@
         uiUnaryIdx--;
       }
+#endif
     }
   }
@@ -775,4 +842,21 @@
   for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ )
   {
+#if POZNAN_DBMP
+	if(bDBMPAvailable)
+	{
+	  if(uiIdx==POZNAN_DBMP_MERGE_POS) uiModIdx = POZNAN_DBMP_MRG_CAND;
+	  else if(uiIdx>POZNAN_DBMP_MERGE_POS) uiModIdx = uiIdx--;
+	  else uiModIdx = uiIdx;
+	}
+	else uiModIdx = uiIdx;
+	if( pcCU->getNeighbourCandIdx( uiModIdx, uiAbsPartIdx ) == uiModIdx + 1 )
+	{
+	  uiNumCand++;
+	}
+	else if( uiIdx < uiMergeIdx )
+	{
+	  uiUnaryIdx--;
+	}
+#else
     if( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) == uiIdx + 1 )
     {
@@ -783,4 +867,5 @@
       uiUnaryIdx--;
     }
+#endif
   }
 #endif
@@ -806,4 +891,5 @@
 Void TEncCavlc::codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
+/* todo JAcek sprawdzic co jest zgane
 #if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
 #if HHI_INTER_VIEW_MOTION_PRED && HHI_MPI
@@ -814,5 +900,18 @@
 #else
   if( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE )
-#endif
+#endif//*/
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
+  if( 
+#if HHI_INTER_VIEW_MOTION_PRED
+	  ( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ) ||
+#endif
+#if HHI_MPI
+	  ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ||
+#endif
+#if	POZNAN_DBMP  
+	  ( pcCU->getSlice()->getMP()->isDBMPEnabled() ) ||
+#endif
+	  0
+    )
   {
     codeMergeIndexMV( pcCU, uiAbsPartIdx );
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCavlc.h	(revision 28)
@@ -228,5 +228,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
   Void codeMergeIndexMV  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCfg.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCfg.h	(revision 28)
@@ -206,4 +206,10 @@
   UInt        m_uiMultiviewResPredMode;
 #endif
+#if POZNAN_DBMP
+  UInt		  m_uiDBMP;
+#endif
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  UInt		  m_uiUseCUSkip;
+#endif
 
   PicOrderCnt m_iQpChangeFrame;
@@ -217,4 +223,16 @@
 #endif
 
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Bool      m_bUseTexDqpAccordingToDepth;
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double      m_dTexDqpAccordingToDepthOffset;
+  Double      m_dTexDqpAccordingToDepthMul;
+  Int         m_iTexDqpAccordingToDepthTopBottomRow; 
+#endif
+#if POZNAN_NONLINEAR_DEPTH
+  Float 	m_fDepthPower;
+#endif
+
 public:
   TEncCfg()          {}
@@ -258,4 +276,12 @@
 #endif
 
+#if POZNAN_DBMP
+  Void      setDBMP						              ( UInt  u )      { m_uiDBMP     = u; }
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Void      setUseCUSkip                       ( UInt  u )      { m_uiUseCUSkip   = u; }
+#endif
+
 #if HHI_INTERVIEW_SKIP
   Void      setInterViewSkip            ( UInt  u )       { m_uiInterViewSkip         = u; }
@@ -306,4 +332,11 @@
   Void      setAllowNegDist                 ( Bool b  )     { m_bAllowNegDist     = b; };
 #endif
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+  inline Float   getDepthPower()               { return m_fDepthPower; }
+  inline Void    setDepthPower(Float p)        { m_fDepthPower = p; }
+#else
+ inline Float    getDepthPower()               { return 1.0f; }
 #endif
 
@@ -478,4 +511,9 @@
   Void setQpChangeOffsetDepth( Int iOffset ) { m_iQpChangeOffsetDepth = iOffset; }
   Int  getQpChangeOffsetDepth() { return m_iQpChangeOffsetDepth; }
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  Bool      getUseTexDqpAccordingToDepth    ()             { return m_bUseTexDqpAccordingToDepth; }
+  Void      setUseTexDqpAccordingToDepth    ( Bool b )     { m_bUseTexDqpAccordingToDepth = b;    }
+#endif
 };
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCu.cpp	(revision 28)
@@ -67,4 +67,11 @@
   m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
   m_ppcResPredTmp  = new TComYuv*[m_uhTotalDepth-1];
+#if POZNAN_AVAIL_MAP
+  m_ppcAvailYuv    = new TComYuv*[m_uhTotalDepth-1];
+#endif
+#if POZNAN_SYNTH_VIEW
+  m_ppcSynthYuv    = new TComYuv*[m_uhTotalDepth-1];
+#endif
+  
 
 #if HHI_MPI
@@ -93,4 +100,12 @@
     m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight);
 
+#if POZNAN_AVAIL_MAP
+    m_ppcAvailYuv   [i] = new TComYuv; m_ppcAvailYuv    [i]->create(uiWidth, uiHeight);
+#endif
+#if POZNAN_SYNTH_VIEW
+    m_ppcSynthYuv   [i] = new TComYuv; m_ppcSynthYuv    [i]->create(uiWidth, uiHeight);
+#endif
+
+
     m_ppcResPredTmp [i] = new TComYuv; m_ppcResPredTmp [i]->create(uiWidth, uiHeight);
   }
@@ -152,4 +167,16 @@
       m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
     }
+#if POZNAN_AVAIL_MAP
+    if(m_ppcAvailYuv[i])
+    {
+      m_ppcAvailYuv[i]->destroy();    delete m_ppcAvailYuv[i];    m_ppcAvailYuv[i]    = NULL;
+    }
+#endif
+#if POZNAN_SYNTH_VIEW
+    if(m_ppcSynthYuv[i])
+    {
+      m_ppcSynthYuv[i]->destroy();    delete m_ppcSynthYuv[i];    m_ppcSynthYuv[i]    = NULL;
+    }
+#endif
     if(m_ppcResPredTmp[i])
     {
@@ -203,4 +230,18 @@
     m_ppcOrigYuv = NULL;
   }
+#if POZNAN_AVAIL_MAP
+  if(m_ppcAvailYuv)
+  {
+    delete [] m_ppcAvailYuv;
+    m_ppcAvailYuv = NULL;
+  }
+#endif
+#if POZNAN_SYNTH_VIEW
+  if(m_ppcSynthYuv)
+  {
+    delete [] m_ppcSynthYuv;
+    m_ppcSynthYuv = NULL;
+  }
+#endif
   if(m_ppcResPredTmp)
   {
@@ -354,4 +395,10 @@
     }
   }
+
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+  //save motion data for every CU point
+  xSaveDBMPData(m_ppcBestCU[0]);
+#endif
+
 }
 
@@ -426,5 +473,39 @@
   // get Original YUV data from picture
   m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
-
+#if POZNAN_AVAIL_MAP
+  if (pcPic->getPicYuvAvail())  m_ppcAvailYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvAvail(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
+#endif  
+#if POZNAN_SYNTH_VIEW
+  if (pcPic->getPicYuvSynth())  m_ppcSynthYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvSynth(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() );
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Bool bWholeCUCanBeSynthesized = false;
+  Bool bOneSubCUCanNotBeSynthesied = false;
+  Bool bSubCUCanBeSynthesized[4];
+  Bool * pbSubCUCanBeSynthesized = bSubCUCanBeSynthesized;
+  pcPic->checkSynthesisAvailability(rpcBestCU, rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth, pbSubCUCanBeSynthesized); //KUBA SYNTH
+  Int  iSubCUCanNotBeSynthesized = 0;
+  Int  iSubCUCanBeSynthesizedCnt = 0;
+  for(Int i = 0; i < 4; i++)
+  {
+    if (!bSubCUCanBeSynthesized[i])
+    {
+      iSubCUCanNotBeSynthesized = i;
+    }
+    else
+    {
+      iSubCUCanBeSynthesizedCnt ++;
+    }
+  }
+  if(iSubCUCanBeSynthesizedCnt == 4)
+  {
+    bWholeCUCanBeSynthesized = true;
+  }
+  else if(iSubCUCanBeSynthesizedCnt == 3)
+  {
+    bOneSubCUCanNotBeSynthesied = true;
+  }
+#endif
   // variables for fast encoder decision
   TComDataCU* pcTempCU;
@@ -493,4 +574,158 @@
   if( ( uiRPelX < rpcBestCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < rpcBestCU->getSlice()->getSPS()->getHeight() ) )
   {
+    // do CU Skip
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    if(bWholeCUCanBeSynthesized)
+    {
+      rpcBestCU->getTotalCost() = 0;       // Cost of synthesised CU is zero
+      rpcBestCU->getTotalBits() = 0;       // Cost of synthesised CU is zero
+      rpcBestCU->getTotalDistortion() = 0; // Distortion of synthesised CU is zero
+      rpcBestCU->setPredModeSubParts( MODE_SYNTH,      0, uiDepth );
+      rpcBestCU->setPartSizeSubParts( SIZE_2Nx2N,      0, uiDepth );
+#if POZNAN_FILL_OCCLUDED_CU_WITH_SYNTHESIS
+      m_ppcRecoYuvBest[uiDepth]->copyFromPicYuv(pcPic->getPicYuvSynth(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU()); // First copy synthesis YUV part to CU encoder reconstruction YUV structure
+#else
+      m_ppcRecoYuvBest[uiDepth]->copyFromPicYuv(pcPic->getPicYuvAvail(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU()); // First copy synthesis YUV part to CU encoder reconstruction YUV structure
+#endif
+      UInt uiInitTrDepth  = rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
+      rpcBestCU->copyToPic(uiDepth, 0, uiInitTrDepth); 
+      xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth );   // Next copy it to reconstruction YUV buffer in coded picture
+      assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE  ); //Not needed any more ??
+      assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE  );
+      assert( rpcBestCU->getTotalCost     (   ) != MAX_DOUBLE );
+
+      #if HHI_VSO//??
+      if( m_pcRdCost->getUseRenModel() )
+      {
+        UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
+        UInt  uiHeight    = rpcBestCU->getHeight( 0 );
+        Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
+        UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride();
+        m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+      }
+      #endif
+      return;
+    }
+    else if (bOneSubCUCanNotBeSynthesied && (uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )) // If only one from subCU can not be synthesised than force NxN split but donot signal it in the stream
+    {
+      //printf("CUSkip - OneCanNotBe %d %d %d\n",rpcBestCU->getCUPelX(),rpcBestCU->getCUPelY(),rpcBestCU->getWidth());
+      // further split !!!!go to line 866!!!
+#if HHI_VSO
+    // reset Model
+    if( m_pcRdCost->getUseRenModel() )
+    {
+      UInt  uiWidth     = m_ppcBestCU[uiDepth]->getWidth ( 0 );
+      UInt  uiHeight    = m_ppcBestCU[uiDepth]->getHeight( 0 );
+      Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 );
+      UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();
+      m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+    }
+#endif
+
+      UChar       uhNextDepth         = uiDepth + 1;
+      TComDataCU* pcSubBestPartCU     = m_ppcBestCU[uhNextDepth];
+      TComDataCU* pcSubTempPartCU     = m_ppcTempCU[uhNextDepth];
+      
+      for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) //UInt uiPartUnitIdx = iSubCUNotSynthesied;
+      {
+        pcSubBestPartCU->initSubCU( rpcBestCU, uiPartUnitIdx, uhNextDepth );           // clear sub partition datas or init.
+        pcSubTempPartCU->initSubCU( rpcBestCU, uiPartUnitIdx, uhNextDepth );           // clear sub partition datas or init.
+//        pcSubBestPartCU->setLastCodedQP( rpcBestCU->getLastCodedQP() );
+//        pcSubTempPartCU->setLastCodedQP( rpcBestCU->getLastCodedQP() );
+        
+        if( ( pcSubBestPartCU->getCUPelX() < pcSubBestPartCU->getSlice()->getSPS()->getWidth() ) && ( pcSubBestPartCU->getCUPelY() < pcSubBestPartCU->getSlice()->getSPS()->getHeight() ) )
+        {
+          if( m_bUseSBACRD )
+          {
+            if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer
+            {
+              m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
+            }
+            else
+            {
+              m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]);
+            }
+          }
+          
+          xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth ); //Compress SubCU's
+          
+#if HHI_VSO
+          if( m_pcRdCost->getUseRenModel() )
+          {
+            UInt  uiWidth     = pcSubBestPartCU->getWidth ( 0 );
+            UInt  uiHeight    = pcSubBestPartCU->getHeight( 0 );
+            Pel*  piSrc       = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getLumaAddr( 0 );
+            UInt  uiSrcStride = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getStride();
+            m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+          }
+#endif
+          rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth );         // Keep best part data to current temporary data.
+          xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth );
+        }
+      }
+
+      if( !bBoundary )
+      {
+        m_pcEntropyCoder->resetBits();
+        m_pcEntropyCoder->encodeSplitFlag( rpcTempCU, 0, uiDepth, true );
+
+        rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
+      }
+
+#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
+      if( bFullyRenderedSec )
+      {
+        m_pcRdCost->setLambdaScale( m_pcEncCfg->getInterViewSkipLambdaScale() );
+      }
+      else
+      {
+        m_pcRdCost->setLambdaScale( 1 );
+      }
+#endif
+#if HHI_VSO
+      if ( m_pcRdCost->getUseLambdaScaleVSO())
+      {
+        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+      }
+      else
+#endif
+      {
+        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+      }    
+
+      if( m_bUseSBACRD )
+      {
+        m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
+      }
+      //Copy Tmp to Best
+      xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth );  //Roznica z naszym koder                                          // RD compare current larger prediction
+
+#if HHI_VSO
+      if( m_pcRdCost->getUseRenModel() )
+      {
+        UInt  uiWidth     = rpcBestCU->getWidth ( 0 );
+        UInt  uiHeight    = rpcBestCU->getHeight( 0 );
+        Pel*  piSrc       = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );
+        UInt  uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride();
+        m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+      }
+#endif
+      //Copy result to pic
+      rpcBestCU->copyToPic(uiDepth);                                                     // Copy Best data to Picture for next partition prediction.
+      
+      if( bBoundary )
+        return;
+
+      xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth );   // Copy Yuv data to picture Yuv
+      
+      // Assert if Best prediction mode is NONE
+      // Selected mode's RD-cost must be not MAX_DOUBLE.
+      assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE  ); //Not needed any more?
+      assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE  );
+      assert( rpcBestCU->getTotalCost     (   ) != MAX_DOUBLE );
+      return;
+    }
+#endif
+
     // do inter modes
     if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
@@ -836,4 +1071,9 @@
   TComPic* pcPic = pcCU->getPic();
 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  if( pcCU->isCUSkiped( uiAbsPartIdx ) && uiDepth == pcCU->getDepth( uiAbsPartIdx )) //If CU Skiped no information is coded into stream
+    return;
+#endif
+
   Bool bBoundary = false;
   UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
@@ -842,6 +1082,30 @@
   UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  Bool bDontSendSplitFlag = false;
+  if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < (g_uiMaxCUDepth-g_uiAddCUDepth) ) ) || bBoundary ) //check if CU has 3 synthesied subCU - no split flag is send in that case
+  {
+    UInt uiQNumParts = ( pcPic->getNumPartInCU() >> (uiDepth<<1) )>>2;
+    Int iCUSkipCounter = 0;
+    UInt uiAbsPartIdxTmp = uiAbsPartIdx;
+    for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdxTmp+=uiQNumParts )
+    {
+      if(pcCU->isCUSkiped(uiAbsPartIdxTmp) && (pcCU->getDepth( uiAbsPartIdxTmp ) == uiDepth + 1) )
+      {
+        iCUSkipCounter++;
+      }
+    } 
+    if(iCUSkipCounter == 3)
+    {
+      bDontSendSplitFlag = true;
+    }
+  }
+#endif
+
   if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) )
   {
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+    if(!bDontSendSplitFlag)
+#endif
 #if HHI_MPI
     if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) )
@@ -1019,4 +1283,7 @@
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
   UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand
+#if POZNAN_DBMP_CALC_PRED_DATA
+  TComMP* pcMP = rpcTempCU->getSlice()->getMP();
+#endif
 
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -1075,6 +1342,16 @@
         rpcTempCU->setNeighbourCandIdxSubParts( uiInner, uiNeighbourCandIdx[uiInner], 0, 0,uhDepth );
       }
+#if POZNAN_DBMP_CALC_PRED_DATA
+	  if(uiMergeCand==POZNAN_DBMP_MRG_CAND)
+	  {
+		rpcTempCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+		rpcTempCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+	  }
+	  else
+#endif
+	  {
       rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
       rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), SIZE_2Nx2N, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+	  }
 
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -1090,5 +1367,18 @@
       if ( uiNoResidual == 0 ){
 #endif
+
+#if POZNAN_DBMP
+		if(uiMergeCand==POZNAN_DBMP_MRG_CAND){
+			m_pcPredSearch->motionCompensation_DBMP ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#if POZNAN_DBMP_CALC_PRED_DATA		
+		  pcMP->setDBMPPredMVField(REF_PIC_LIST_0, rpcTempCU);
+		  pcMP->setDBMPPredMVField(REF_PIC_LIST_1, rpcTempCU);
+#endif
+		}
+		else
         m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#else 
+        m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#endif
         // save pred adress
         pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth];
@@ -1100,4 +1390,12 @@
           pcPredYuvTemp = m_ppcPredYuvBest[uhDepth];
         }
+#if POZNAN_DBMP_CALC_PRED_DATA
+	    if(uiMergeCand==POZNAN_DBMP_MRG_CAND)
+	    {
+	      //copy motion data representing CU with DBMP for uiNoResidual==0 case		
+	      rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->copyFrom(pcMP->getDBMPPredMVField(REF_PIC_LIST_0),rpcTempCU->getTotalNumPart(),0);
+	      rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->copyFrom(pcMP->getDBMPPredMVField(REF_PIC_LIST_1),rpcTempCU->getTotalNumPart(),0);
+	    }
+#endif
       }
 #if HHI_VSO
@@ -1123,6 +1421,17 @@
       Bool bQtRootCbf = rpcTempCU->getQtRootCbf(0) == 1;
 #else
+#if POZNAN_DBMP
       // do MC
+	  if(uiMergeCand==POZNAN_DBMP_MRG_CAND){
+		 m_pcPredSearch->motionCompensation_DBMP ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+#if POZNAN_DBMP_CALC_PRED_DATA		
+		 pcMP->setDBMPPredMVField(REF_PIC_LIST_0, rpcTempCU);
+		 pcMP->setDBMPPredMVField(REF_PIC_LIST_1, rpcTempCU);
+#endif		
+	  }
+	  else
       m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+
+#endif
 
       // estimate residual and encode everything
@@ -1412,5 +1721,9 @@
     for( UInt ui = 0; ui < rpcTempCU->getTotalNumPart(); ui++ )
     {
-      if( pcTextureCU->isIntra( rpcTempCU->getZorderIdxInCU() + ui ) )
+      if( pcTextureCU->isIntra( rpcTempCU->getZorderIdxInCU() + ui ) 
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+        || pcTextureCU->isCUSkiped( rpcTempCU->getZorderIdxInCU() + ui )
+#endif
+      )
       {
         return;
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCu.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncCu.h	(revision 28)
@@ -78,4 +78,10 @@
   TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
   TComYuv**               m_ppcResPredTmp;  ///< Temporary residual prediction for each depth
+#if POZNAN_AVAIL_MAP
+  TComYuv**               m_ppcAvailYuv;    ///< Avaiability map for each depth  
+#endif
+#if POZNAN_SYNTH_VIEW
+  TComYuv**               m_ppcSynthYuv;    ///< Synthetized Yuv for each depth
+#endif
   
   //  Data : encoder control
@@ -156,4 +162,8 @@
   Void  xRestoreDepthWidthHeight( TComDataCU* pcCU );
 #endif
+
+#if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA
+  Void  xSaveDBMPData(TComDataCU* pcCU) { pcCU->getSlice()->getMP()->saveDBMPData(pcCU);}
+#endif
 };
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 28)
@@ -293,4 +293,16 @@
 #endif
 
+#if POZNAN_MP    
+#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
+	  pcSlice->getMP()->setDepthMapGenerator(m_pcDepthMapGenerator);
+#else
+      std::vector<TComPic*> apcSpatDepthRefPics = m_pcEncTop->getEncTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), true );
+	  pcSlice->getMP()->setDepthRefPicsList(&apcSpatDepthRefPics);
+#endif
+	  std::vector<TComPic*> apcSpatDataRefPics = m_pcEncTop->getEncTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), m_pcEncTop->isDepthCoder() );
+	  pcSlice->getMP()->setRefPicsList(&apcSpatDataRefPics);
+	  pcSlice->getMP()->pairMultiview(pcPic);
+#endif
+
       while(uiNextCUAddr<pcPic->getPicSym()->getNumberOfCUsInFrame()) // determine slice boundaries
       {
@@ -615,4 +627,8 @@
       pcBitstreamOut->convertRBSPToPayload(0);
 
+#if POZNAN_MP
+	  //pcSlice->getMP()->disable();
+#endif
+
 /*#if AMVP_BUFFERCOMPRESS
       pcPic->compressMotion(); // moved to end of access unit
@@ -799,4 +815,10 @@
   Pel*  pOrg    = pcPic ->getPicYuvOrg()->getLumaAddr();
   Pel*  pRec    = pcPicD->getLumaAddr();
+#if POZNAN_CU_SKIP_PSNR
+  Pel*  pAvail  = NULL;
+  if(pcPic ->getPicYuvAvail())
+    pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
+  UInt64 iPixelsCnt = 0;
+#endif
   Int   iStride = pcPicD->getStride();
 
@@ -813,13 +835,38 @@
   Double fRefValueC = fRefValueY / 4.0;
 
+#if POZNAN_CU_SKIP_PSNR
+  if(pAvail)
+  {
   for( y = 0; y < iHeight; y++ )
   {
     for( x = 0; x < iWidth; x++ )
     {
+        if(pAvail[x]==0) //If pixel was codded
+        {
       Int iDiff = (Int)( pOrg[x] - pRec[x] );
       uiSSDY   += iDiff * iDiff;
+          iPixelsCnt++;
+        }
     }
     pOrg += iStride;
     pRec += iStride;
+      pAvail+=iStride;
+    }
+    
+    fRefValueY = (double) maxval * maxval * iPixelsCnt;
+  }
+  else
+#endif
+  {
+    for( y = 0; y < iHeight; y++ )
+    {
+      for( x = 0; x < iWidth; x++ )
+      {
+        Int iDiff = (Int)( pOrg[x] - pRec[x] );
+        uiSSDY   += iDiff * iDiff;
+      }
+      pOrg += iStride;
+      pRec += iStride;
+    }
   }
 
@@ -837,34 +884,89 @@
 #endif
   {
-  iHeight >>= 1;
-  iWidth  >>= 1;
-  iStride >>= 1;
-  pOrg  = pcPic ->getPicYuvOrg()->getCbAddr();
-  pRec  = pcPicD->getCbAddr();
-
-  for( y = 0; y < iHeight; y++ )
-  {
-    for( x = 0; x < iWidth; x++ )
-    {
-      Int iDiff = (Int)( pOrg[x] - pRec[x] );
-      uiSSDU   += iDiff * iDiff;
-    }
-    pOrg += iStride;
-    pRec += iStride;
-  }
-
-  pOrg  = pcPic ->getPicYuvOrg()->getCrAddr();
-  pRec  = pcPicD->getCrAddr();
-
-  for( y = 0; y < iHeight; y++ )
-  {
-    for( x = 0; x < iWidth; x++ )
-    {
-      Int iDiff = (Int)( pOrg[x] - pRec[x] );
-      uiSSDV   += iDiff * iDiff;
-    }
-    pOrg += iStride;
-    pRec += iStride;
-  }
+#if POZNAN_CU_SKIP_PSNR
+    if(pAvail)
+    {
+      iHeight >>= 1;
+      iWidth  >>= 1;
+      iStride >>= 1;
+    
+      pOrg  = pcPic ->getPicYuvOrg()->getCbAddr();
+      pRec  = pcPicD->getCbAddr();
+      pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
+      iPixelsCnt = 0;
+
+      for( y = 0; y < iHeight; y++ )
+      {
+        for( x = 0; x < iWidth; x++ )
+        {
+          if(pAvail[x<<1]==0||pAvail[(x<<1)+1]==0||
+             pAvail[(x+iStride)<<1]==0||pAvail[((x+iStride)<<1)+1]==0) //If pixel was codded
+          {
+            Int iDiff = (Int)( pOrg[x] - pRec[x] );
+            uiSSDU   += iDiff * iDiff;
+            iPixelsCnt++;
+          }
+        }
+        pOrg += iStride;
+        pRec += iStride;
+        pAvail+= (iStride<<2);
+      }
+      
+      fRefValueC = (double) maxval * maxval * iPixelsCnt;
+
+      pOrg  = pcPic ->getPicYuvOrg()->getCrAddr();
+      pRec  = pcPicD->getCrAddr();
+      pAvail  = pcPic ->getPicYuvAvail()->getLumaAddr();
+      for( y = 0; y < iHeight; y++ )
+      {
+        for( x = 0; x < iWidth; x++ )
+        {
+          if(pAvail[x<<1]==0||pAvail[(x<<1)+1]==0||
+             pAvail[(x+iStride)<<1]==0||pAvail[((x+iStride)<<1)+1]==0) //If pixel was codded
+          {
+            Int iDiff = (Int)( pOrg[x] - pRec[x] );
+            uiSSDV   += iDiff * iDiff;
+          }
+        }
+        pOrg += iStride;
+        pRec += iStride;
+        pAvail+= iStride<<2;
+      }
+    }
+    else
+#endif
+    {
+      iHeight >>= 1;
+      iWidth  >>= 1;
+      iStride >>= 1;
+      pOrg  = pcPic ->getPicYuvOrg()->getCbAddr();
+      pRec  = pcPicD->getCbAddr();
+
+      for( y = 0; y < iHeight; y++ )
+      {
+        for( x = 0; x < iWidth; x++ )
+        {
+          Int iDiff = (Int)( pOrg[x] - pRec[x] );
+          uiSSDU   += iDiff * iDiff;
+        }
+        pOrg += iStride;
+        pRec += iStride;
+      }
+
+      pOrg  = pcPic ->getPicYuvOrg()->getCrAddr();
+      pRec  = pcPicD->getCrAddr();
+
+      for( y = 0; y < iHeight; y++ )
+      {
+        for( x = 0; x < iWidth; x++ )
+        {
+          Int iDiff = (Int)( pOrg[x] - pRec[x] );
+          uiSSDV   += iDiff * iDiff;
+        }
+        pOrg += iStride;
+        pRec += iStride;
+      }
+    }
+
   dYPSNR            = ( uiSSDY ? 10.0 * log10( fRefValueY / (Double)uiSSDY ) : 99.99 );
   dUPSNR            = ( uiSSDU ? 10.0 * log10( fRefValueC / (Double)uiSSDU ) : 99.99 );
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 28)
@@ -660,5 +660,5 @@
 
 
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
 Void TEncSbac::codeMergeIndexMV( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
@@ -670,4 +670,7 @@
   const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : MRG_MAX_NUM_CANDS;
 #endif
+#if POZNAN_DBMP
+  const Bool bDBMPAvailable = pcCU->getSlice()->getMP()->isDBMPEnabled();
+#endif
   for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ )
   {
@@ -692,4 +695,32 @@
     }
   }
+
+#if POZNAN_DBMP
+  if(bDBMPAvailable)
+  {
+    UInt uiDBMPMergePos = POZNAN_DBMP_MERGE_POS;
+#if HHI_MPI
+	if(bMVIAvailable && uiDBMPMergePos>=uiMviMergePos) uiDBMPMergePos++;
+#endif
+	for( Int iIdx = MRG_MAX_NUM_CANDS-2; iIdx >= (Int)uiDBMPMergePos; iIdx-- )
+	{
+		Int iWrIdx = iIdx+1;
+#if HHI_MPI
+		if(bMVIAvailable) 
+		{
+			if(iIdx==(Int)uiMviMergePos) continue;
+			if(iWrIdx==(Int)uiMviMergePos) iWrIdx++;
+		}
+#endif
+		if(iWrIdx>=MRG_MAX_NUM_CANDS) continue;
+
+		abAvailable[ iWrIdx ] = abAvailable[ iIdx ];
+	}
+	abAvailable[ uiDBMPMergePos ] = ( pcCU->getNeighbourCandIdx( POZNAN_DBMP_MRG_CAND, uiAbsPartIdx ) == POZNAN_DBMP_MRG_CAND + 1 );
+	
+	uiNumCand = 0; for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) if(abAvailable[ uiIdx ]) uiNumCand++;
+  }
+#endif
+
   AOF( uiNumCand > 1 );
 
@@ -718,4 +749,11 @@
   //--- determine unary index ---
   UInt  uiMergeIdx  = pcCU->getMergeIndex( uiAbsPartIdx );
+#if POZNAN_DBMP
+  if(bDBMPAvailable)
+  {
+	if(uiMergeIdx==POZNAN_DBMP_MRG_CAND)  uiMergeIdx = POZNAN_DBMP_MERGE_POS;
+	else if(uiMergeIdx>=POZNAN_DBMP_MERGE_POS) uiMergeIdx++;
+  }
+#endif
 #if HHI_MPI
   if( bMVIAvailable )
@@ -783,4 +821,5 @@
 Void TEncSbac::codeMergeIndex( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
+/* todo jacek niech sie wypowie
 #if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
 #if HHI_INTER_VIEW_MOTION_PRED && HHI_MPI
@@ -791,5 +830,18 @@
 #else
   if( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE )
-#endif
+#endif//*/
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
+  if( 
+#if HHI_INTER_VIEW_MOTION_PRED	  
+	  ( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ) ||
+#endif
+#if HHI_MPI
+      ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )  ||
+#endif
+#if	POZNAN_DBMP  
+	  ( pcCU->getSlice()->getMP()->isDBMPEnabled() ) ||
+#endif
+	  0
+    )
   {
     codeMergeIndexMV( pcCU, uiAbsPartIdx );
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSbac.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSbac.h	(revision 28)
@@ -166,5 +166,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
+#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP
   Void codeMergeIndexMV  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 28)
@@ -1042,5 +1042,9 @@
   UInt uiAbsSum = 0;
   pcCU       ->setTrIdxSubParts ( uiTrDepth, uiAbsPartIdx, uiFullDepth );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant    ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
   m_pcTrQuant->setQPforQuant    ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
   m_pcTrQuant->transformNxN     ( pcCU, piResi, uiStride, pcCoeff, uiWidth, uiHeight, uiAbsSum, TEXT_LUMA, uiAbsPartIdx );
 
@@ -1208,5 +1212,9 @@
     //--- transform and quantization ---
     UInt uiAbsSum = 0;
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_pcTrQuant->setQPforQuant       ( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, true), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
     m_pcTrQuant->setQPforQuant     ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
     m_pcTrQuant->transformNxN      ( pcCU, piResi, uiStride, pcCoeff, uiWidth, uiHeight, uiAbsSum, eText, uiAbsPartIdx );
     //--- set coded block flag ---
@@ -2814,4 +2822,50 @@
 }
 
+#if POZNAN_DBMP
+Void TEncSearch::xGetInterPredictionError_DBMP( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiErr, Bool bHadamard )
+{
+  TComYuv cYuvPred;
+  cYuvPred.create( pcYuvOrg->getWidth(), pcYuvOrg->getHeight() );
+
+#ifdef WEIGHT_PRED
+  UInt uiAbsPartIdx = 0;
+  Int iWidth = 0;
+  Int iHeight = 0;
+  //Int iRefIdx[2];
+  pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
+
+//???????????????????????????????????????????????????????????????????????????????????
+  //iRefIdx[0] = pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiAbsPartIdx );
+  //iRefIdx[1] = pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiAbsPartIdx );
+  //if ( iRefIdx[0]>=0 && iRefIdx[1]<1 )
+  //  setWpScalingDistParam( pcCU, iRefIdx[0], iRefIdx[1], REF_PIC_LIST_0);
+  //else
+  //  setWpScalingDistParam( pcCU, iRefIdx[0], iRefIdx[1], REF_PIC_LIST_1);
+  setWpScalingDistParam( pcCU, -1, -1, REF_PIC_LIST_X);//???
+//???????????????????????????????????????????????????????????????????????????????????
+  motionCompensation_DBMP( pcCU, &cYuvPred, REF_PIC_LIST_X, iPartIdx );
+#else
+  motionCompensation_DBMP( pcCU, &cYuvPred, REF_PIC_LIST_X, iPartIdx );
+
+  UInt uiAbsPartIdx = 0;
+  Int iWidth = 0;
+  Int iHeight = 0;
+  pcCU->getPartIndexAndSize( iPartIdx, uiAbsPartIdx, iWidth, iHeight );
+#endif
+
+  DistParam cDistParam;
+#ifdef WEIGHT_PRED
+  cDistParam.applyWeight = false;
+#endif
+  m_pcRdCost->setDistParam( cDistParam, 
+                            pcYuvOrg->getLumaAddr( uiAbsPartIdx ), pcYuvOrg->getStride(), 
+                            cYuvPred .getLumaAddr( uiAbsPartIdx ), cYuvPred .getStride(), 
+                            iWidth, iHeight, m_pcEncCfg->getUseHADME() );
+  ruiErr = cDistParam.DistFunc( &cDistParam );
+
+  cYuvPred.destroy();
+}
+#endif
+
 /** estimation of best merge coding
  * \param pcCU
@@ -2875,8 +2929,25 @@
       PartSize ePartSize = pcCU->getPartitionSize( 0 );
 
+#if POZNAN_DBMP_CALC_PRED_DATA
+	  if(uiMergeCand==POZNAN_DBMP_MRG_CAND)
+	  {
+		pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
+		pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
+	  }
+	  else
+#endif
+	  {
       pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[0 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
       pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand].getMv(), cMvFieldNeighbours[1 + 2*uiMergeCand].getRefIdx(), ePartSize, uiAbsPartIdx, iPUIdx, 0 );
-
+	  }
+
+#if POZNAN_DBMP
+	  if(uiMergeCand==POZNAN_DBMP_MRG_CAND)
+		xGetInterPredictionError_DBMP( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
+	  else
       xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
+#else
+      xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
+#endif
 
       if( uiNumCand == 1 )
@@ -2886,19 +2957,32 @@
       else
       {
-        if( uiMergeCand == 0 || uiNumCand == 2 )
+        UInt uiMergeCandIdx = uiMergeCand;
+#if POZNAN_DBMP
+		if(pcCU->getSlice()->getMP()->isDBMPEnabled())
+		{
+			if(uiMergeCand == POZNAN_DBMP_MRG_CAND) uiMergeCandIdx = POZNAN_DBMP_MERGE_POS;
+			else if(uiMergeCand >= POZNAN_DBMP_MERGE_POS) uiMergeCandIdx++;
+		}
+#endif
+
+        if( uiMergeCandIdx == 0 || uiNumCand == 2 )
         {
           uiBitsCand = 2;
         }
-        else if( uiMergeCand == 1 || uiNumCand == 3 )
+        else if( uiMergeCandIdx == 1 || uiNumCand == 3 )
         {
           uiBitsCand = 3;
         }
-        else if( uiMergeCand == 2 || uiNumCand == 4 )
+        else if( uiMergeCandIdx == 2 || uiNumCand == 4 )
         {
           uiBitsCand = 4;
         }
+		else if( uiMergeCandIdx == 3 || uiNumCand == 5 )
+        {
+          uiBitsCand = 5;
+        }
         else
         {
-          uiBitsCand = 5;
+          uiBitsCand = 6;
         }
       }
@@ -2910,4 +2994,20 @@
         pacMvField[0] = cMvFieldNeighbours[0 + 2*uiMergeCand];
         pacMvField[1] = cMvFieldNeighbours[1 + 2*uiMergeCand];
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+		if(uiMergeCand==POZNAN_DBMP_MRG_CAND)
+		{
+			TComCUMvField* pcDBMPPredMvField;
+
+			pcDBMPPredMvField = pcCU->getSlice()->getMP()->getDBMPPredMVField(REF_PIC_LIST_0);
+			pcDBMPPredMvField->setMv(pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(uiAbsPartIdx),0);
+			pcDBMPPredMvField->setRefIdx(pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx),0);
+
+			pcDBMPPredMvField = pcCU->getSlice()->getMP()->getDBMPPredMVField(REF_PIC_LIST_1);
+			pcDBMPPredMvField->setMv(pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(uiAbsPartIdx),0);
+			pcDBMPPredMvField->setRefIdx(pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx),0);
+		}
+#endif
+
         uiInterDir = uhInterDirNeighbours[uiMergeCand];
         uiMergeIndex = uiMergeCand;
@@ -3604,4 +3704,19 @@
         pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+
+#if POZNAN_DBMP_CALC_PRED_DATA
+		if(uiMRGIndex==POZNAN_DBMP_MRG_CAND)
+		{
+			TComCUMvField* pcDBMPPredMvField;
+			pcDBMPPredMvField = pcCU->getSlice()->getMP()->getDBMPPredMVField(REF_PIC_LIST_0);
+			pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( pcDBMPPredMvField->getMv(0), pcDBMPPredMvField->getRefIdx(0), ePartSize, uiPartAddr, iPartIdx, 0 );			
+			pcDBMPPredMvField = pcCU->getSlice()->getMP()->getDBMPPredMVField(REF_PIC_LIST_1);
+			pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( pcDBMPPredMvField->getMv(0), pcDBMPPredMvField->getRefIdx(0), ePartSize, uiPartAddr, iPartIdx, 0 );
+
+			pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0].getMv(), cMRGMvField[0].getRefIdx(), ePartSize, uiPartAddr, iPartIdx, 0 );
+			pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1].getMv(), cMRGMvField[1].getRefIdx(), ePartSize, uiPartAddr, iPartIdx, 0 );
+		}
+		else
+#endif
         {
           pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0].getMv(), cMRGMvField[0].getRefIdx(), ePartSize, uiPartAddr, iPartIdx, 0 );
@@ -4998,5 +5113,9 @@
       m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, 1<< uiLog2TrSize, TEXT_LUMA );
     }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
     m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
     m_pcTrQuant->transformNxN( pcCU, pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride (), pcCoeffCurrY, 1<< uiLog2TrSize,    1<< uiLog2TrSize,    uiAbsSumY, TEXT_LUMA,     uiAbsPartIdx );
 
@@ -5009,5 +5128,9 @@
         m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, 1<<uiLog2TrSizeC, TEXT_CHROMA );
       }
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
       m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
       m_pcTrQuant->transformNxN( pcCU, pcResi->getCbAddr( uiAbsPartIdx ), pcResi->getCStride(), pcCoeffCurrU, 1<<uiLog2TrSizeC, 1<<uiLog2TrSizeC, uiAbsSumU, TEXT_CHROMA_U, uiAbsPartIdx );
       m_pcTrQuant->transformNxN( pcCU, pcResi->getCrAddr( uiAbsPartIdx ), pcResi->getCStride(), pcCoeffCurrV, 1<<uiLog2TrSizeC, 1<<uiLog2TrSizeC, uiAbsSumV, TEXT_CHROMA_V, uiAbsPartIdx );
@@ -5072,5 +5195,9 @@
     {
       Pel *pcResiCurrY = m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+      m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false),  false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#else
       m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_LUMA );
+#endif
 #if INTRA_DST_TYPE_7 // Inside Inter Encoder Search. So use conventional DCT.
     m_pcTrQuant->invtransformNxN( TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, 1<< uiLog2TrSize,    1<< uiLog2TrSize );//this is for inter mode only
@@ -5150,5 +5277,9 @@
       {
         Pel *pcResiCurrU = m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( uiAbsPartIdx );
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+        m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
         m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
 #if INTRA_DST_TYPE_7  // Inside Inter Encoder Search. So use conventional DCT.
         m_pcTrQuant->invtransformNxN( TEXT_CHROMA,REG_DCT, pcResiCurrU, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrU, 1<<uiLog2TrSizeC, 1<<uiLog2TrSizeC);
@@ -5195,5 +5326,9 @@
         if( !uiAbsSumU )
         {
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+          m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ) + pcCU->getQpOffsetForTextCU(uiAbsPartIdx, false), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#else
           m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), false, pcCU->getSlice()->getSliceType(), TEXT_CHROMA );
+#endif
         }
 #if INTRA_DST_TYPE_7   // Inside Inter Encoder Search. So use conventional DCT.
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSearch.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncSearch.h	(revision 28)
@@ -185,4 +185,7 @@
   
   Void xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiSAD, Bool Hadamard );
+#if POZNAN_DBMP
+  Void xGetInterPredictionError_DBMP( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, UInt& ruiSAD, Bool Hadamard );
+#endif
 
 public:
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncTop.cpp	(revision 28)
@@ -63,4 +63,9 @@
   m_bSeqFirst = true;
   m_iFrameNumInCodingOrder = 0;
+    
+#if POZNAN_MP
+  m_pcMP=NULL;
+#endif
+
 }
 
@@ -98,4 +103,8 @@
 #endif
 
+#if POZNAN_MP
+  m_pcMP				= NULL;
+#endif
+
 #if MQT_BA_RA && MQT_ALF_NPASS
   if(m_bUseALF)
@@ -163,4 +172,8 @@
 #endif
 
+#if POZNAN_MP
+  m_pcMP=NULL;
+#endif
+
   // SBAC RD
   if( m_bUseSBACRD )
@@ -205,4 +218,8 @@
   // initialize PPS
   xInitPPS();
+#endif
+
+#if POZNAN_MP
+  m_pcMP = pcTAppEncTop->getMP();
 #endif
 
@@ -416,4 +433,13 @@
   {
     pcPic->removeOriginalBuffer   ();
+#if POZNAN_AVAIL_MAP
+    pcPic->removeAvailabilityBuffer();
+#endif
+#if POZNAN_SYNTH_VIEW
+    pcPic->removeSynthesisBuffer();
+#endif
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+    pcPic->removeSynthesisDepthBuffer();
+#endif
 #if HHI_INTER_VIEW_MOTION_PRED
     pcPic->removeOrgDepthMapBuffer();
@@ -508,4 +534,8 @@
   // mark it should be extended
   rpcPic->getPicYuvRec()->setBorderExtension(false);
+
+#if POZNAN_MP
+  rpcPic->getSlice(0)->setMP(m_pcMP);
+#endif
 }
 
@@ -579,4 +609,9 @@
     }
   }
+
+#if POZNAN_DBMP
+  m_cSPS.setDBMP  ( m_uiDBMP );
+#endif
+
   m_cSPS.setSPSId( ( m_uiViewId << 1 ) + ( m_bIsDepth ? 1 : 0 ) );
 
@@ -618,4 +653,17 @@
 #if HHI_MPI
   m_cSPS.setUseMVI( m_bUseMVI );
+#endif
+
+#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
+  m_cSPS.setUseCUSkip( m_uiUseCUSkip );
+#endif
+
+#if POZNAN_NONLINEAR_DEPTH
+  m_cSPS.setDepthPower  ( m_fDepthPower );
+  // OLGIERD: ToDo - QP-Tex should not use getDepthPower() from texture SPS.
+#endif
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
+  m_cSPS.setUseTexDqpAccordingToDepth  ( m_bUseTexDqpAccordingToDepth );
 #endif
 
@@ -821,3 +869,9 @@
 
   pcPic->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset );
-}
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+    pcPic->setTexDqpAccordingToDepthOffset( getTexDqpAccordingToDepthOffset() );
+    pcPic->setTexDqpAccordingToDepthMul   ( getTexDqpAccordingToDepthMul() );
+    pcPic->setTexDqpAccordingToDepthTopBottomRow( getTexDqpAccordingToDepthTopBottomRow() );  
+#endif
+}
Index: /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncTop.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibEncoder/TEncTop.h	(revision 28)
@@ -64,4 +64,7 @@
 #include "TEncAnalyze.h"
 
+#if POZNAN_MP
+#include "../TLibCommon/TComMP.h"
+#endif		
 
 // ====================================================================================================================
@@ -131,4 +134,13 @@
 
   PicOrderCnt             m_iFrameNumInCodingOrder;
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double                m_dTexDqpAccordingToDepthOffset;
+  Double                m_dTexDqpAccordingToDepthMul;
+  Int                   m_iTexDqpAccordingToDepthTopBottomRow; 
+#endif
+
+#if POZNAN_MP
+  TComMP*				  m_pcMP;
+#endif
 
 protected:
@@ -217,4 +229,13 @@
   Void encode    ( bool bEos, std::map<PicOrderCnt, TComPicYuv*>& rcMapPicYuvRecOut, TComBitstream* pcBitstreamOut, Bool& bNewPicNeeded );
   Void receivePic( bool bEos, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvRec, TComPicYuv* pcOrgPdmDepth = 0 );
+
+#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC 
+  Double getTexDqpAccordingToDepthOffset( )      { return m_dTexDqpAccordingToDepthOffset;}
+  Double getTexDqpAccordingToDepthMul( )         { return m_dTexDqpAccordingToDepthMul;}
+  Int    getTexDqpAccordingToDepthTopBottomRow( ){ return m_iTexDqpAccordingToDepthTopBottomRow;}
+  Void   setTexDqpAccordingToDepthOffset      ( Double dTexDqpAccordingToDepthOffset    ){ m_dTexDqpAccordingToDepthOffset       = dTexDqpAccordingToDepthOffset; }
+  Void   setTexDqpAccordingToDepthMul         ( Double dTexDqpAccordingToDepthMul       ){ m_dTexDqpAccordingToDepthMul          = dTexDqpAccordingToDepthMul; }
+  Void   setTexDqpAccordingToDepthTopBottomRow( Int iTexDqpAccordingToDepthTopBottomRow ){ m_iTexDqpAccordingToDepthTopBottomRow = iTexDqpAccordingToDepthTopBottomRow; }  
+#endif
 };
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenFilter.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenFilter.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenFilter.cpp	(revision 28)
@@ -66,5 +66,5 @@
   riBlendDistWeight = bBlendUseDistWeight ? iRelDistToLeft :  1 << (REN_VDWEIGHT_PREC - 1);
 
-  for (UInt uiDepthValue = 0; uiDepthValue <= 256; uiDepthValue++)
+  for (UInt uiDepthValue = 0; uiDepthValue <= SizeOfLUT; uiDepthValue++)
   {
     //GT: retrieve depth approx from shift
@@ -73,5 +73,5 @@
   }
   // Set Threshold
-  riBlendZThres  = ( max( abs(piInvZLUTLeft[0]- piInvZLUTLeft[255]), abs(piInvZLUTRight[0]- piInvZLUTRight[255]) ) * iBlendZThresPerc + 50)  / 100;
+  riBlendZThres  = ( max( abs(piInvZLUTLeft[0]- piInvZLUTLeft[SizeOfLUT-1]), abs(piInvZLUTRight[0]- piInvZLUTRight[SizeOfLUT-1]) ) * iBlendZThresPerc + 50)  / 100;
 }
 
Index: /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenSingleModel.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 28)
@@ -139,6 +139,6 @@
   if (m_iMode == 2)
   {
-    m_piInvZLUTLeft  = new Int[257];
-    m_piInvZLUTRight = new Int[257];
+    m_piInvZLUTLeft  = new Int[SizeOfLUT+1];
+    m_piInvZLUTRight = new Int[SizeOfLUT+1];
   }
 
@@ -448,5 +448,5 @@
       m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );
       xExtrapolateMarginL  ( iCurSPos, iEndChangePos, iError );
-      iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMinChangedSPos       = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
       iLastSPos             = iCurSPos;
       m_iLastDepth          = m_iCurDepth;
@@ -466,5 +466,5 @@
     {
       // Get minimal changed sample position
-      iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
       Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
       m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
@@ -541,5 +541,5 @@
       m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );
       xExtrapolateMarginR     ( iCurSPos, iStartChangePos, iError );
-      iMaxChangedSPos       = Max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMaxChangedSPos       = Max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]);
       iLastSPos             = iCurSPos;
       m_iLastDepth          = m_iCurDepth;
@@ -559,5 +559,5 @@
     {
       // Get minimal changed sample position
-      iMaxChangedSPos = Max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
+      iMaxChangedSPos = Max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]);
       Int iCurSPos    = xShiftNewData(iCurPosX,iPosXinNewData);
       m_iCurDepth     = m_piNewDepthData[iPosXinNewData];
@@ -948,5 +948,5 @@
   AOF( iPosInNewData < m_iNewDataWidth );
 
-  return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_piNewDepthData[iPosInNewData] )];
+  return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( m_piNewDepthData[iPosInNewData] )];
 }
 
@@ -956,5 +956,5 @@
  AOT( iPosX <        0);
  AOF( iPosX < m_iWidth);
- return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )];
+ return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrementLUT( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )];
 }
 
@@ -1149,6 +1149,6 @@
       m_aapiSynthVideoPelRow                                   [1][2][iTargetSPos]  ,
 #endif
-      m_piInvZLUTLeft [RemoveBitIncrement(m_iThisDepth)                            ],
-      m_piInvZLUTRight[RemoveBitIncrement(m_apiSynthDepthPelRow[1]   [iTargetSPos])],
+      m_piInvZLUTLeft [RemoveBitIncrementLUT(m_iThisDepth)                            ],
+      m_piInvZLUTRight[RemoveBitIncrementLUT(m_apiSynthDepthPelRow[1]   [iTargetSPos])],
       iFilled,
       m_apiFilledRow                                           [1]   [iTargetSPos]  ,
@@ -1171,6 +1171,6 @@
       m_aapiBaseVideoPelRow                                    [1][2][iSourcePos ],
 #endif
-      m_piInvZLUTLeft [RemoveBitIncrement(m_apiSynthDepthPelRow[0]   [iTargetSPos])],
-      m_piInvZLUTRight[RemoveBitIncrement(m_iThisDepth)                            ],
+      m_piInvZLUTLeft [RemoveBitIncrementLUT(m_apiSynthDepthPelRow[0]   [iTargetSPos])],
+      m_piInvZLUTRight[RemoveBitIncrementLUT(m_iThisDepth)                            ],
       m_apiFilledRow                                           [0]   [iTargetSPos],
       iFilled                                                                     ,
Index: /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenTop.cpp
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenTop.cpp	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenTop.cpp	(revision 28)
@@ -242,5 +242,5 @@
     for( UInt uiPlane = 0; uiPlane < 2; uiPlane++)
     {
-      for (UInt uiDepthValue = 0; uiDepthValue <= 256; uiDepthValue++)
+      for (UInt uiDepthValue = 0; uiDepthValue <= SizeOfLUT; uiDepthValue++)
       {
         m_ppdShiftLUTRightMirror[uiPlane][uiDepthValue] = - m_ppdShiftLUTRight[uiPlane][uiDepthValue];
@@ -280,4 +280,33 @@
 };
 
+#if POZNAN_SYNTH
+Void TRenTop::extrapolateAvailabilityView( TComPicYuv* pcPicYuvVideo, TComPicYuv* pcPicYuvDepth, TComPicYuv* pcPicYuvSynthOut, TComPicYuv* pcPicYuvAvailOut, Bool bRenderFromLeft )
+{
+  AOF( m_bExtrapolate );
+  AOF( bRenderFromLeft ? m_ppiShiftLUTLeft || m_ppdShiftLUTLeft : m_ppiShiftLUTRight || m_ppdShiftLUTRight );
+  AOF( m_auiInputResolution[0] == pcPicYuvVideo->getWidth ());
+  AOF( m_auiInputResolution[1] == pcPicYuvVideo->getHeight());
+
+  PelImage cInputImage ( pcPicYuvVideo    );
+  PelImage cInputDepth ( pcPicYuvDepth    , true);
+  PelImage cOutputImage( pcPicYuvSynthOut );
+  PelImage cFillImage( pcPicYuvAvailOut );
+    
+  m_pcOutputImage->init();
+  m_pcFilled     ->assign(REN_IS_HOLE);
+  
+  xPreProcessDepth ( &cInputDepth,  &cInputDepth);
+  xConvertInputData( &cInputImage, &cInputDepth, m_pcInputImage, m_pcInputDepth, !bRenderFromLeft );
+  xShiftPixels(m_pcInputImage, m_pcInputDepth, m_pcOutputImage, &cFillImage, bRenderFromLeft);
+  xRemBoundaryNoise ( m_pcOutputImage, &cFillImage, m_pcOutputImage, bRenderFromLeft); // Erode
+  xFillHoles        ( m_pcOutputImage, &cFillImage, m_pcOutputImage, bRenderFromLeft);
+  xConvertOutputData( m_pcOutputImage, &cOutputImage, !bRenderFromLeft );
+  if (!bRenderFromLeft)  TRenFilter::mirrorHor( &cFillImage );
+  //xConvertOutputData( m_pcFilled, &cFillImage, !bRenderFromLeft );
+  xPostProcessImage (&cOutputImage, &cOutputImage);
+  xCutMargin        ( &cOutputImage );
+};
+#endif
+
 Void TRenTop::getUsedSamplesMap( TComPicYuv* pcPicYuvDepth, TComPicYuv* pcUsedSampleMap, Bool bRenderFromLeft )
 {
@@ -469,5 +498,5 @@
 
       // compute disparity and shift
-      iShiftedPos  = ( iPosX << m_iRelShiftLUTPrec ) - m_aiShiftLUTCur[RemoveBitIncrement( pcDepthData[iPosX])];
+      iShiftedPos  = ( iPosX << m_iRelShiftLUTPrec ) - m_aiShiftLUTCur[RemoveBitIncrementLUT( pcDepthData[iPosX])];
 
       if (iPosX == 0)
@@ -623,6 +652,6 @@
 
         // compute disparity and shift
-        assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 );
-        dPrevShiftedPos  = (Double) iPosX - m_adShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])];
+        assert( RemoveBitIncrementLUT(pcDepthData[iPosX]) >= 0 && RemoveBitIncrementLUT(pcDepthData[iPosX]) <= SizeOfLUT );
+        dPrevShiftedPos  = (Double) iPosX - m_adShiftLUTCur[ RemoveBitIncrementLUT(pcDepthData[iPosX])];
 
         if (iPosX == 0)
@@ -804,6 +833,6 @@
     for(Int iPosX = 0; iPosX < iWidth; iPosX++)
     {
-      assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 );
-      Int iShiftedPos = iPosX - m_aiShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])] ;
+      assert( RemoveBitIncrementLUT(pcDepthData[iPosX]) >= 0 && RemoveBitIncrementLUT(pcDepthData[iPosX]) <= SizeOfLUT );
+      Int iShiftedPos = iPosX - m_aiShiftLUTCur[ RemoveBitIncrementLUT(pcDepthData[iPosX])] ;
       if (iShiftedPos < iWidth && iShiftedPos >= 0)
       {
@@ -879,5 +908,5 @@
     for(Int iPosX = 0; iPosX < iOutputWidth; iPosX ++)
     {
-      Int iBackShiftedPos = (iPosX << m_iRelShiftLUTPrec) - m_aiShiftLUTCur[ RemoveBitIncrement( pcDepthData[iPosX] )];
+      Int iBackShiftedPos = (iPosX << m_iRelShiftLUTPrec) - m_aiShiftLUTCur[ RemoveBitIncrementLUT( pcDepthData[iPosX] )];
       if( ( pcFilledData[iPosX] == REN_IS_FILLED )  && (iBackShiftedPos >= 0 ) && ( iBackShiftedPos < iInputWidth ) )
       {
@@ -952,5 +981,5 @@
     {
       // compute disparity and shift
-      iShiftedPos  =  iPosX - m_aiShiftLUTCur[RemoveBitIncrement(pcDepthData[iPosX])];
+      iShiftedPos  =  iPosX - m_aiShiftLUTCur[RemoveBitIncrementLUT(pcDepthData[iPosX])];
 
       if ( iPosX == 0 )
@@ -1837,5 +1866,5 @@
         if      (  (pcFilledRightData[uiXPos] != REN_IS_HOLE ) && ( pcFilledLeftData[uiXPos] != REN_IS_HOLE) )
         {
-          Int iDepthDifference  = m_piInvZLUTLeft[RemoveBitIncrement(pcLeftDepthData[uiXPos])] - m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])];
+          Int iDepthDifference  = m_piInvZLUTLeft[RemoveBitIncrementLUT(pcLeftDepthData[uiXPos])] - m_piInvZLUTRight[RemoveBitIncrementLUT(pcRightDepthData[uiXPos])];
 
           if ( abs ( iDepthDifference ) <= m_iBlendZThres )
@@ -1866,5 +1895,5 @@
         else if ( (pcFilledRightData[uiXPos] == REN_IS_HOLE) && (pcFilledLeftData[uiXPos] == REN_IS_HOLE))
         {
-          pcOutputData[uiXPos] = m_piInvZLUTLeft[RemoveBitIncrement( pcLeftDepthData[uiXPos])]  < m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])] ? pcLeftVideoData[uiXPos] : pcRightVideoData[uiXPos];
+          pcOutputData[uiXPos] = m_piInvZLUTLeft[RemoveBitIncrementLUT( pcLeftDepthData[uiXPos])]  < m_piInvZLUTRight[RemoveBitIncrementLUT(pcRightDepthData[uiXPos])] ? pcLeftVideoData[uiXPos] : pcRightVideoData[uiXPos];
         }
         else
@@ -2030,6 +2059,6 @@
 
   m_ppdShiftLUTRightMirror    = new Double*[2];
-  m_ppdShiftLUTRightMirror[0] = new Double [257];
-  m_ppdShiftLUTRightMirror[1] = new Double [257];
+  m_ppdShiftLUTRightMirror[0] = new Double [SizeOfLUT+1];
+  m_ppdShiftLUTRightMirror[1] = new Double [SizeOfLUT+1];
 
   m_adShiftLUTCur    = 0;
@@ -2038,10 +2067,10 @@
   m_ppiShiftLUTRight = 0;
   m_ppiShiftLUTRightMirror    = new Int*[2];
-  m_ppiShiftLUTRightMirror[0] = new Int[257];
-  m_ppiShiftLUTRightMirror[1] = new Int[257];
+  m_ppiShiftLUTRightMirror[0] = new Int[SizeOfLUT+1];
+  m_ppiShiftLUTRightMirror[1] = new Int[SizeOfLUT+1];
 
   m_aiShiftLUTCur    = 0;
-  m_piInvZLUTLeft  = new Int[257];
-  m_piInvZLUTRight = new Int[257];
+  m_piInvZLUTLeft  = new Int[SizeOfLUT+1];
+  m_piInvZLUTRight = new Int[SizeOfLUT+1];
 
   // Buffers
Index: /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenTop.h
===================================================================
--- /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenTop.h	(revision 27)
+++ /branches/0.3-poznan-univ/source/Lib/TLibRenderer/TRenTop.h	(revision 28)
@@ -109,4 +109,13 @@
                            Int         iBlendMode,
                            Int         iSimEnhBaseView );
+
+#if POZNAN_SYNTH
+  Void extrapolateAvailabilityView   
+                         ( TComPicYuv* pcPicYuvVideo, 
+                           TComPicYuv* pcPicYuvDepth, 
+                           TComPicYuv* pcPicYuvSynthOut, 
+                           TComPicYuv* pcPicYuvAvailOut, 
+                           Bool bRenderFromLeft );
+#endif
   // Tools
   Void getUsedSamplesMap ( TComPicYuv* pcPicYuvDepth,
