Changeset 1427 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibCommon
- Timestamp:
- 5 Aug 2015, 20:04:35 (10 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibCommon
- Files:
-
- 2 edited
-
TComPicYuv.cpp (modified) (7 diffs)
-
TComPicYuv.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp
r1416 r1427 78 78 79 79 80 81 Void TComPicYuv::create ( const Int iPicWidth, ///< picture width 82 const Int iPicHeight, ///< picture height 83 const ChromaFormat chromaFormatIDC, ///< chroma format 84 const UInt uiMaxCUWidth, ///< used for generating offsets to CUs. Can use iPicWidth if no offsets are required 85 const UInt uiMaxCUHeight, ///< used for generating offsets to CUs. Can use iPicHeight if no offsets are required 86 const UInt uiMaxCUDepth, ///< used for generating offsets to CUs. Can use 0 if no offsets are required 80 Void TComPicYuv::createWithoutCUInfo ( const Int picWidth, ///< picture width 81 const Int picHeight, ///< picture height 82 const ChromaFormat chromaFormatIDC, ///< chroma format 83 const Bool bUseMargin, ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 84 const UInt maxCUWidth, ///< used for margin only 85 const UInt maxCUHeight ///< used for margin only 87 86 #if SVC_EXTENSION 88 const Bool bUseMargin, ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 89 const Window* conformanceWindow) 90 #else 91 const Bool bUseMargin) ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 92 #endif 87 , const Window* conformanceWindow 88 #endif 89 ) 93 90 94 91 { … … 101 98 #endif 102 99 103 m_ iPicWidth = iPicWidth;104 m_ iPicHeight = iPicHeight;100 m_picWidth = picWidth; 101 m_picHeight = picHeight; 105 102 m_chromaFormatIDC = chromaFormatIDC; 106 m_ iMarginX = (bUseMargin?uiMaxCUWidth:0) + 16; // for 16-byte alignment107 m_ iMarginY = (bUseMargin?uiMaxCUHeight:0) + 16; // margin for 8-tap filter and infinite padding103 m_marginX = (bUseMargin?maxCUWidth:0) + 16; // for 16-byte alignment 104 m_marginY = (bUseMargin?maxCUHeight:0) + 16; // margin for 8-tap filter and infinite padding 108 105 m_bIsBorderExtended = false; 109 106 110 107 // assign the picture arrays and set up the ptr to the top left of the original picture 111 { 112 Int chan=0; 113 for(; chan<getNumberValidComponents(); chan++) 114 { 115 const ComponentID ch=ComponentID(chan); 116 m_apiPicBuf[chan] = (Pel*)xMalloc( Pel, getStride(ch) * getTotalHeight(ch)); 117 m_piPicOrg[chan] = m_apiPicBuf[chan] + (m_iMarginY >> getComponentScaleY(ch)) * getStride(ch) + (m_iMarginX >> getComponentScaleX(ch)); 118 } 119 for(;chan<MAX_NUM_COMPONENT; chan++) 120 { 121 m_apiPicBuf[chan] = NULL; 122 m_piPicOrg[chan] = NULL; 123 } 124 } 125 126 127 const Int numCuInWidth = m_iPicWidth / uiMaxCUWidth + (m_iPicWidth % uiMaxCUWidth != 0); 128 const Int numCuInHeight = m_iPicHeight / uiMaxCUHeight + (m_iPicHeight % uiMaxCUHeight != 0); 129 for(Int chan=0; chan<2; chan++) 130 { 131 const ComponentID ch=ComponentID(chan); 132 const Int ctuHeight=uiMaxCUHeight>>getComponentScaleY(ch); 133 const Int ctuWidth=uiMaxCUWidth>>getComponentScaleX(ch); 134 const Int stride = getStride(ch); 108 for(UInt comp=0; comp<getNumberValidComponents(); comp++) 109 { 110 const ComponentID ch=ComponentID(comp); 111 m_apiPicBuf[comp] = (Pel*)xMalloc( Pel, getStride(ch) * getTotalHeight(ch)); 112 m_piPicOrg[comp] = m_apiPicBuf[comp] + (m_marginY >> getComponentScaleY(ch)) * getStride(ch) + (m_marginX >> getComponentScaleX(ch)); 113 } 114 // initialize pointers for unused components to NULL 115 for(UInt comp=getNumberValidComponents();comp<MAX_NUM_COMPONENT; comp++) 116 { 117 m_apiPicBuf[comp] = NULL; 118 m_piPicOrg[comp] = NULL; 119 } 120 121 for(Int chan=0; chan<MAX_NUM_CHANNEL_TYPE; chan++) 122 { 123 m_ctuOffsetInBuffer[chan] = NULL; 124 m_subCuOffsetInBuffer[chan] = NULL; 125 } 126 } 127 128 129 130 Void TComPicYuv::create ( const Int picWidth, ///< picture width 131 const Int picHeight, ///< picture height 132 const ChromaFormat chromaFormatIDC, ///< chroma format 133 const UInt maxCUWidth, ///< used for generating offsets to CUs. 134 const UInt maxCUHeight, ///< used for generating offsets to CUs. 135 const UInt maxCUDepth, ///< used for generating offsets to CUs. 136 const Bool bUseMargin ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 137 #if SVC_EXTENSION 138 , const Window* conformanceWindow 139 #endif 140 ) 141 142 { 143 #if SVC_EXTENSION 144 createWithoutCUInfo(picWidth, picHeight, chromaFormatIDC, bUseMargin, maxCUWidth, maxCUHeight, conformanceWindow); 145 #else 146 createWithoutCUInfo(picWidth, picHeight, chromaFormatIDC, bUseMargin, maxCUWidth, maxCUHeight); 147 #endif 148 149 150 const Int numCuInWidth = m_picWidth / maxCUWidth + (m_picWidth % maxCUWidth != 0); 151 const Int numCuInHeight = m_picHeight / maxCUHeight + (m_picHeight % maxCUHeight != 0); 152 for(Int chan=0; chan<MAX_NUM_CHANNEL_TYPE; chan++) 153 { 154 const ChannelType ch= ChannelType(chan); 155 const Int ctuHeight = maxCUHeight>>getChannelTypeScaleY(ch); 156 const Int ctuWidth = maxCUWidth>>getChannelTypeScaleX(ch); 157 const Int stride = getStride(ch); 135 158 136 159 m_ctuOffsetInBuffer[chan] = new Int[numCuInWidth * numCuInHeight]; … … 144 167 } 145 168 146 m_subCuOffsetInBuffer[chan] = new Int[(size_t)1 << (2 * uiMaxCUDepth)];147 148 const Int numSubBlockPartitions=(1<< uiMaxCUDepth);149 const Int minSubBlockHeight =(ctuHeight >> uiMaxCUDepth);150 const Int minSubBlockWidth =(ctuWidth >> uiMaxCUDepth);169 m_subCuOffsetInBuffer[chan] = new Int[(size_t)1 << (2 * maxCUDepth)]; 170 171 const Int numSubBlockPartitions=(1<<maxCUDepth); 172 const Int minSubBlockHeight =(ctuHeight >> maxCUDepth); 173 const Int minSubBlockWidth =(ctuWidth >> maxCUDepth); 151 174 152 175 for (Int buRow = 0; buRow < numSubBlockPartitions; buRow++) … … 154 177 for (Int buCol = 0; buCol < numSubBlockPartitions; buCol++) 155 178 { 156 m_subCuOffsetInBuffer[chan][(buRow << uiMaxCUDepth) + buCol] = stride * buRow * minSubBlockHeight + buCol * minSubBlockWidth; 157 } 158 } 159 } 160 return; 161 } 162 163 179 m_subCuOffsetInBuffer[chan][(buRow << maxCUDepth) + buCol] = stride * buRow * minSubBlockHeight + buCol * minSubBlockWidth; 180 } 181 } 182 } 183 } 164 184 165 185 Void TComPicYuv::destroy() 166 186 { 167 for(Int c han=0; chan<MAX_NUM_COMPONENT; chan++)168 { 169 m_piPicOrg[c han] = NULL;170 171 if( m_apiPicBuf[c han] )172 { 173 xFree( m_apiPicBuf[c han] );174 m_apiPicBuf[c han] = NULL;187 for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++) 188 { 189 m_piPicOrg[comp] = NULL; 190 191 if( m_apiPicBuf[comp] ) 192 { 193 xFree( m_apiPicBuf[comp] ); 194 m_apiPicBuf[comp] = NULL; 175 195 } 176 196 } … … 195 215 Void TComPicYuv::copyToPic (TComPicYuv* pcPicYuvDst) const 196 216 { 197 assert( m_iPicWidth == pcPicYuvDst->getWidth(COMPONENT_Y) );198 assert( m_iPicHeight == pcPicYuvDst->getHeight(COMPONENT_Y) );199 217 assert( m_chromaFormatIDC == pcPicYuvDst->getChromaFormat() ); 200 218 201 for(Int chan=0; chan<getNumberValidComponents(); chan++) 202 { 203 const ComponentID ch=ComponentID(chan); 204 ::memcpy ( pcPicYuvDst->getBuf(ch), m_apiPicBuf[ch], sizeof (Pel) * getStride(ch) * getTotalHeight(ch)); 205 } 206 return; 219 for(Int comp=0; comp<getNumberValidComponents(); comp++) 220 { 221 const ComponentID compId=ComponentID(comp); 222 const Int width = getWidth(compId); 223 const Int height = getHeight(compId); 224 const Int strideSrc = getStride(compId); 225 assert(pcPicYuvDst->getWidth(compId) == width); 226 assert(pcPicYuvDst->getHeight(compId) == height); 227 if (strideSrc==pcPicYuvDst->getStride(compId)) 228 { 229 ::memcpy ( pcPicYuvDst->getBuf(compId), getBuf(compId), sizeof(Pel)*strideSrc*getTotalHeight(compId)); 230 } 231 else 232 { 233 const Pel *pSrc = getAddr(compId); 234 Pel *pDest = pcPicYuvDst->getAddr(compId); 235 const UInt strideDest = pcPicYuvDst->getStride(compId); 236 237 for(Int y=0; y<height; y++, pSrc+=strideSrc, pDest+=strideDest) 238 { 239 ::memcpy(pDest, pSrc, width*sizeof(Pel)); 240 } 241 } 242 } 207 243 } 208 244 … … 215 251 } 216 252 217 for(Int c han=0; chan<getNumberValidComponents(); chan++)218 { 219 const ComponentID c h=ComponentID(chan);220 Pel *piTxt=getAddr(c h); // piTxt = point to (0,0) of image within bigger picture.221 const Int iStride=getStride(ch);222 const Int iWidth=getWidth(ch);223 const Int iHeight=getHeight(ch);224 const Int iMarginX=getMarginX(ch);225 const Int iMarginY=getMarginY(ch);253 for(Int comp=0; comp<getNumberValidComponents(); comp++) 254 { 255 const ComponentID compId=ComponentID(comp); 256 Pel *piTxt=getAddr(compId); // piTxt = point to (0,0) of image within bigger picture. 257 const Int stride=getStride(compId); 258 const Int width=getWidth(compId); 259 const Int height=getHeight(compId); 260 const Int marginX=getMarginX(compId); 261 const Int marginY=getMarginY(compId); 226 262 227 263 Pel* pi = piTxt; 228 264 // do left and right margins 229 for (Int y = 0; y < iHeight; y++)230 { 231 for (Int x = 0; x < iMarginX; x++ )232 { 233 pi[ - iMarginX + x ] = pi[0];234 pi[ iWidth + x ] = pi[iWidth-1];235 } 236 pi += iStride;265 for (Int y = 0; y < height; y++) 266 { 267 for (Int x = 0; x < marginX; x++ ) 268 { 269 pi[ -marginX + x ] = pi[0]; 270 pi[ width + x ] = pi[width-1]; 271 } 272 pi += stride; 237 273 } 238 274 239 275 // pi is now the (0,height) (bottom left of image within bigger picture 240 pi -= ( iStride + iMarginX);276 pi -= (stride + marginX); 241 277 // pi is now the (-marginX, height-1) 242 for (Int y = 0; y < iMarginY; y++ )243 { 244 ::memcpy( pi + (y+1)* iStride, pi, sizeof(Pel)*(iWidth + (iMarginX<<1)) );278 for (Int y = 0; y < marginY; y++ ) 279 { 280 ::memcpy( pi + (y+1)*stride, pi, sizeof(Pel)*(width + (marginX<<1)) ); 245 281 } 246 282 247 283 // pi is still (-marginX, height-1) 248 pi -= (( iHeight-1) * iStride);284 pi -= ((height-1) * stride); 249 285 // pi is now (-marginX, 0) 250 for (Int y = 0; y < iMarginY; y++ )251 { 252 ::memcpy( pi - (y+1)* iStride, pi, sizeof(Pel)*(iWidth + (iMarginX<<1)) );286 for (Int y = 0; y < marginY; y++ ) 287 { 288 ::memcpy( pi - (y+1)*stride, pi, sizeof(Pel)*(width + (marginX<<1)) ); 253 289 } 254 290 } … … 273 309 274 310 275 for(Int c han = 0; chan < getNumberValidComponents(); chan++)276 { 277 const ComponentID c h = ComponentID(chan);278 const Int shift = bitDepths.recon[toChannelType(c h)] - 8;311 for(Int comp = 0; comp < getNumberValidComponents(); comp++) 312 { 313 const ComponentID compId = ComponentID(comp); 314 const Int shift = bitDepths.recon[toChannelType(compId)] - 8; 279 315 const Int offset = (shift>0)?(1<<(shift-1)):0; 280 const Pel *pi = getAddr(c h);281 const Int stride = getStride(c h);282 const Int height = getHeight(c h);283 const Int width = getWidth(c h);316 const Pel *pi = getAddr(compId); 317 const Int stride = getStride(compId); 318 const Int height = getHeight(compId); 319 const Int width = getWidth(compId); 284 320 285 321 for (Int y = 0; y < height; y++ ) -
branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h
r1289 r1427 71 71 // ------------------------------------------------------------------------------------------------ 72 72 73 Int m_ iPicWidth;///< Width of picture in pixels74 Int m_ iPicHeight;///< Height of picture in pixels73 Int m_picWidth; ///< Width of picture in pixels 74 Int m_picHeight; ///< Height of picture in pixels 75 75 ChromaFormat m_chromaFormatIDC; ///< Chroma Format 76 76 … … 78 78 Int* m_subCuOffsetInBuffer[MAX_NUM_CHANNEL_TYPE];///< Gives an offset in the buffer for a given sub-CU (and channel), relative to start of CTU 79 79 80 Int m_ iMarginX;///< margin of Luma channel (chroma's may be smaller, depending on ratio)81 Int m_ iMarginY;///< margin of Luma channel (chroma's may be smaller, depending on ratio)80 Int m_marginX; ///< margin of Luma channel (chroma's may be smaller, depending on ratio) 81 Int m_marginY; ///< margin of Luma channel (chroma's may be smaller, depending on ratio) 82 82 83 83 Bool m_bIsBorderExtended; … … 96 96 // ------------------------------------------------------------------------------------------------ 97 97 98 Void create (const Int iPicWidth,99 const Int iPicHeight,98 Void create (const Int picWidth, 99 const Int picHeight, 100 100 const ChromaFormat chromaFormatIDC, 101 const UInt uiMaxCUWidth, ///< used for generating offsets to CUs. Can use iPicWidth if no offsets are required 102 const UInt uiMaxCUHeight, ///< used for generating offsets to CUs. Can use iPicHeight if no offsets are required 103 const UInt uiMaxCUDepth, ///< used for generating offsets to CUs. Can use 0 if no offsets are required 104 #if SVC_EXTENSION 105 const Bool bUseMargin, ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 106 const Window* conformanceWindow = NULL); 107 #else 108 const Bool bUseMargin); ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 109 #endif 110 101 const UInt maxCUWidth, ///< used for generating offsets to CUs. 102 const UInt maxCUHeight, ///< used for generating offsets to CUs. 103 const UInt maxCUDepth, ///< used for generating offsets to CUs. 104 const Bool bUseMargin ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 105 #if SVC_EXTENSION 106 , const Window* conformanceWindow = NULL 107 #endif 108 ); 109 110 Void createWithoutCUInfo(const Int picWidth, 111 const Int picHeight, 112 const ChromaFormat chromaFormatIDC, 113 const Bool bUseMargin=false, ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image. 114 const UInt maxCUWidth=0, ///< used for margin only 115 const UInt maxCUHeight=0 ///< used for margin only 116 #if SVC_EXTENSION 117 , const Window* conformanceWindow = NULL 118 #endif 119 ); 120 111 121 Void destroy (); 112 122 … … 119 129 // ------------------------------------------------------------------------------------------------ 120 130 121 Int getWidth (const ComponentID id) const { return m_ iPicWidth >> getComponentScaleX(id); }122 Int getHeight (const ComponentID id) const { return m_ iPicHeight >> getComponentScaleY(id); }131 Int getWidth (const ComponentID id) const { return m_picWidth >> getComponentScaleX(id); } 132 Int getHeight (const ComponentID id) const { return m_picHeight >> getComponentScaleY(id); } 123 133 ChromaFormat getChromaFormat () const { return m_chromaFormatIDC; } 124 134 UInt getNumberValidComponents() const { return ::getNumberValidComponents(m_chromaFormatIDC); } 125 135 126 Int getStride (const ComponentID id) const { return ((m_iPicWidth ) + (m_iMarginX <<1)) >> getComponentScaleX(id); } 127 Int getTotalHeight (const ComponentID id) const { return ((m_iPicHeight ) + (m_iMarginY <<1)) >> getComponentScaleY(id); } 128 129 Int getMarginX (const ComponentID id) const { return m_iMarginX >> getComponentScaleX(id); } 130 Int getMarginY (const ComponentID id) const { return m_iMarginY >> getComponentScaleY(id); } 136 Int getStride (const ComponentID id) const { return ((m_picWidth ) + (m_marginX <<1)) >> getComponentScaleX(id); } 137 private: 138 Int getStride (const ChannelType id) const { return ((m_picWidth ) + (m_marginX <<1)) >> getChannelTypeScaleX(id); } 139 public: 140 Int getTotalHeight (const ComponentID id) const { return ((m_picHeight ) + (m_marginY <<1)) >> getComponentScaleY(id); } 141 142 Int getMarginX (const ComponentID id) const { return m_marginX >> getComponentScaleX(id); } 143 Int getMarginY (const ComponentID id) const { return m_marginY >> getComponentScaleY(id); } 131 144 132 145 // ------------------------------------------------------------------------------------------------ … … 136 149 // Access starting position of picture buffer with margin 137 150 Pel* getBuf (const ComponentID ch) { return m_apiPicBuf[ch]; } 151 const Pel* getBuf (const ComponentID ch) const { return m_apiPicBuf[ch]; } 138 152 139 153 // Access starting position of original picture … … 152 166 UInt getComponentScaleY(const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); } 153 167 168 UInt getChannelTypeScaleX(const ChannelType id) const { return ::getChannelTypeScaleX(id, m_chromaFormatIDC); } 169 UInt getChannelTypeScaleY(const ChannelType id) const { return ::getChannelTypeScaleY(id, m_chromaFormatIDC); } 170 154 171 // ------------------------------------------------------------------------------------------------ 155 172 // Miscellaneous … … 169 186 170 187 #if SVC_EXTENSION 171 Void setHeight ( Int iPicHeight ) { m_iPicHeight = iPicHeight;}188 Void setHeight ( Int picHeight ) { m_picHeight = picHeight; } 172 189 Window& getConformanceWindow() { return m_conformanceWindow; } 173 190 Void setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
Note: See TracChangeset for help on using the changeset viewer.