source: 3DVCSoftware/branches/HTM-3.0-Samsung/source/Lib/TLibRenderer/TRenSingleModel.h @ 85

Last change on this file since 85 was 56, checked in by hschwarz, 13 years ago

updated trunk (move to HM6.1)

  • Property svn:eol-style set to native
File size: 10.4 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2011, ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35#ifndef __TRENSINGLEMODEL__
36#define __TRENSINGLEMODEL__
37
38#include "TRenImage.h"
39#include "../TLibCommon/CommonDef.h"
40#include "../TLibCommon/TComPicYuv.h"
41#include "../TLibCommon/TypeDef.h"
42#include "../TAppCommon/TAppComCamPara.h"
43
44
45#include <math.h>
46#include <errno.h>
47#include <iostream>
48
49#include <string>
50#include <cstdio>
51#include <cstring>
52
53
54using namespace std;
55
56
57class TRenSingleModel
58{
59
60public:
61  TRenSingleModel();
62  ~TRenSingleModel();
63
64  // Create Model
65  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode );
66
67  // Set Frame dependent data
68  Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride );
69  Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference );
70
71  // Set Data
72  Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
73  Void   setVideo  ( Int iViewPos,     Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
74
75  // Get Distortion
76  RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
77  RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
78
79  // Get Rendered Data
80  Void   getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride );
81
82  // Get Reference Data
83  Void   getRefView  ( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides );
84
85private:
86  // Set and inc Current Row
87  __inline Void   xSetViewRow(  Int iPosY );
88  __inline Void   xIncViewRow();
89
90  /////  Rendering /////
91  // Left to Right
92  __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet);
93  __inline Void   xInitRenderPartL    ( Int iEndChangePos, Int iLastSPos  );
94  __inline Void   xRenderRangeL       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
95  __inline Void   xRenderShiftedRangeL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
96  __inline Void   xFillHoleL          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
97  __inline Void   xExtrapolateMarginL ( Int iCurSPos,                Int iCurPos, RMDist& riError );
98  __inline Int    xRangeLeftL         ( Int iPos );
99  __inline Int    xRangeRightL        ( Int iPos );
100  __inline Int    xRoundL             ( Int iPos );
101
102  // Right to Left
103  __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet );
104  __inline Void   xInitRenderPartR    ( Int iStartChangePos, Int iLastSPos );
105  __inline Void   xRenderShiftedRangeR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
106  __inline Void   xRenderRangeR       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
107  __inline Void   xFillHoleR          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
108  __inline Void   xExtrapolateMarginR ( Int iCurSPos,                Int iCurPos, RMDist& riError );
109  __inline Int    xRangeLeftR         ( Int iPos );
110  __inline Int    xRangeRightR        ( Int iPos );
111  __inline Int    xRoundR             ( Int iPos );
112
113  // Blending
114  __inline Void   xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
115
116#if HHI_VSO_COLOR_PLANES
117  __inline Void   xGetBlendedValue    ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );
118  __inline Void   xGetBlendedValueBM1 ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );
119  __inline Void   xGetBlendedValueBM2 ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );
120#else
121  __inline Void   xGetBlendedValue    ( Pel iYL,   Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
122  __inline Void   xGetBlendedValueBM1 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
123  __inline Void   xGetBlendedValueBM2 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
124#endif
125  __inline Pel    xBlend              ( Pel pVal1, Pel pVal2, Int iWeightVal2 );
126
127// General
128  __inline Void   xSetShiftedPel     ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
129  __inline Int    xShiftNewData      ( Int iPos, Int iPosInNewData );
130  __inline Int    xShift             ( Int iPos );
131  __inline Int    xShift             ( Int iPos, Int iPosInNewData );
132  __inline Int    xGetDist           ( Int iDiffY, Int iDiffU, Int iDiffV );
133  __inline Int    xGetDist           ( Int iDiffY );
134
135  // Utilities
136  __inline Void   xInitView  ( Int iViewPos );
137  __inline Void   xSetPels   ( Pel*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
138  __inline Void   xSetBools  ( Bool* pbSource    , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal );
139  __inline Void   xSetInts   ( Int*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal );
140
141private:
142
143  // Image sizes
144  Int   m_iWidth;
145  Int   m_iHeight;
146  Int   m_iStride;
147  Int   m_iPad;
148
149  Int   m_iSampledWidth;
150  Int   m_iSampledHeight;
151  Int   m_iSampledStride;
152
153  // Base
154  Pel** m_aapiBaseVideoPel     [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
155  Int*  m_aaiBaseVideoStrides  [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
156
157  Pel*  m_apiBaseDepthPel      [2]; // Dim1: ViewPosition
158  Int   m_aiBaseDepthStrides   [2]; // Dim1: ViewPosition
159
160  // LUT
161  Int** m_appiShiftLut         [2];
162  Int** m_ppiCurLUT;
163  Int** m_aaiSubPelShiftL;
164  Int** m_aaiSubPelShiftR;
165
166  Int*  m_piInvZLUTLeft;
167  Int*  m_piInvZLUTRight;
168
169
170  //// Reference Data  ////
171  TComPicYuv* m_pcPicYuvRef       ;    // Reference PIcYuv
172  Pel*  m_aapiRefVideoPel      [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
173  Int   m_aiRefVideoStrides    [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
174
175  // Renderer State
176  Int*  m_piError                 ;
177  Pel*  m_apiFilled            [2];    // Dim1: ViewPosition
178  Bool* m_apbOccluded          [2];    // Dim1: ViewPosition
179  Pel*  m_aapiSynthVideoPel    [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
180  Pel*  m_apiSynthDepthPel     [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
181
182  // Rendering State
183  Bool  m_bInOcclusion;                // Currently rendering in occluded area
184  Int   m_iLastOccludedSPos;           // Position of last topmost shifted position
185  Int   m_iLastOccludedSPosFP;         // Position of last topmost shifted position in FullPels
186
187  Bool  m_bSet;                        // Set Data, or get Error
188  Int   m_iCurViewPos;                 // Current View Position 0: Left, 1: Right
189  Int   m_iOtherViewPos;               // Other View Position 0: Left, 1: Right
190  Pel*  m_piNewDepthData;              // Pointer to new depth data
191  Int   m_iStartChangePosX;            // Start Position of new data
192  Int   m_iNewDataWidth;               // Width of new data
193  Pel   m_iCurDepth;                   // Current Depth Value
194  Pel   m_iLastDepth;                  // Last Depth Value
195  Pel   m_iThisDepth;                  // Depth value to use for setting
196
197  //// Settings ////
198  // Input
199  Int   m_iMode;                       // 0: Left to Right, 1: Right to Left, 2: Merge
200  Bool  m_bUseOrgRef;
201  Int   m_iShiftPrec;
202  Int   m_iHoleMargin;
203  Int   m_iBlendMode;
204
205  // Derived settings
206  Int   m_iGapTolerance;
207  Int   m_iBlendZThres;
208  Int   m_iBlendDistWeight;
209
210  //// Current Pointers ////
211  Pel*  m_aapiBaseVideoPelRow  [2][3]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
212  Pel*  m_apiBaseDepthPelRow   [2];    // Dim1: ViewPosition
213  Bool* m_apbOccludedRow       [2];    // Dim1: ViewPosition
214  Pel*  m_apiFilledRow         [2];    // Dim1: ViewPosition
215  Int*  m_apiErrorRow             ;
216
217  Pel*  m_aapiRefVideoPelRow   [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
218  Pel*  m_aapiSynthVideoPelRow [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
219  Pel*  m_apiSynthDepthPelRow  [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged
220
221
222  //// MISC ////
223  const Int m_iDistShift;                  // Shift in Distortion computation
224};
225
226#endif //__TRENSINGLEMODEL__
Note: See TracBrowser for help on using the repository browser.