172 ::memset(dstOffsets, 0,
sizeof(
Int)*MAX_NUM_SAO_CLASSES);
176 for(
Int i=0; i< 4; i++)
197 Int numValidMergeCandidates = 0;
212 mergeCandidate = &(blkParams[mergedCTUPos]);
221 mergedCTUPos = ctuRsAddr- 1;
224 mergeCandidate = &(blkParams[mergedCTUPos]);
231 printf(
"not a supported merge type");
237 mergeList[mergeType]=mergeCandidate;
238 if (mergeCandidate !=
NULL)
240 numValidMergeCandidates++;
244 return numValidMergeCandidates;
251 for(
Int compIdx = 0; compIdx < numberOfComponents; compIdx++)
254 SAOOffset& offsetParam = recParam[component];
271 assert(mergeTarget !=
NULL);
273 offsetParam = (*mergeTarget)[component];
278 printf(
"Not a supported mode");
302 for(
Int compIdx = 0; compIdx < numberOfComponents; compIdx++)
304 if(saoBlkParams[ctuRsAddr][compIdx].modeIdc !=
SAO_MODE_OFF)
315 ,
Bool isLeftAvail,
Bool isRightAvail,
Bool isAboveAvail,
Bool isBelowAvail,
Bool isAboveLeftAvail,
Bool isAboveRightAvail,
Bool isBelowLeftAvail,
Bool isBelowRightAvail)
336 const Int maxSampleValueIncl = (1<< channelBitDepth )-1;
338 Int x,y, startX, startY, endX, endY, edgeType;
339 Int firstLineStartX, firstLineEndX, lastLineStartX, lastLineEndX;
340 SChar signLeft, signRight, signDown;
342 Pel* srcLine = srcBlk;
343 Pel* resLine = resBlk;
350 startX = isLeftAvail ? 0 : 1;
351 endX = isRightAvail ? width : (width -1);
352 for (y=0; y< height; y++)
354 signLeft = (
SChar)
sgn(srcLine[startX] - srcLine[startX-1]);
355 for (x=startX; x< endX; x++)
357 signRight = (
SChar)
sgn(srcLine[x] - srcLine[x+1]);
358 edgeType = signRight + signLeft;
359 signLeft = -signRight;
361 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
363 srcLine += srcStride;
364 resLine += resStride;
374 startY = isAboveAvail ? 0 : 1;
375 endY = isBelowAvail ? height : height-1;
378 srcLine += srcStride;
379 resLine += resStride;
382 Pel* srcLineAbove= srcLine- srcStride;
383 for (x=0; x< width; x++)
385 signUpLine[x] = (
SChar)
sgn(srcLine[x] - srcLineAbove[x]);
389 for (y=startY; y<endY; y++)
391 srcLineBelow= srcLine+ srcStride;
393 for (x=0; x< width; x++)
395 signDown = (
SChar)
sgn(srcLine[x] - srcLineBelow[x]);
396 edgeType = signDown + signUpLine[x];
397 signUpLine[x]= -signDown;
399 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
401 srcLine += srcStride;
402 resLine += resStride;
410 SChar *signUpLine, *signDownLine, *signTmpLine;
415 startX = isLeftAvail ? 0 : 1 ;
416 endX = isRightAvail ? width : (width-1);
419 Pel* srcLineBelow= srcLine+ srcStride;
420 for (x=startX; x< endX+1; x++)
422 signUpLine[x] = (
SChar)
sgn(srcLineBelow[x] - srcLine[x- 1]);
426 Pel* srcLineAbove= srcLine- srcStride;
427 firstLineStartX = isAboveLeftAvail ? 0 : 1;
428 firstLineEndX = isAboveAvail? endX: 1;
429 for(x= firstLineStartX; x< firstLineEndX; x++)
431 edgeType =
sgn(srcLine[x] - srcLineAbove[x- 1]) - signUpLine[x+1];
433 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
435 srcLine += srcStride;
436 resLine += resStride;
440 for (y= 1; y< height-1; y++)
442 srcLineBelow= srcLine+ srcStride;
444 for (x=startX; x<endX; x++)
446 signDown = (
SChar)
sgn(srcLine[x] - srcLineBelow[x+ 1]);
447 edgeType = signDown + signUpLine[x];
448 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
450 signDownLine[x+1] = -signDown;
452 signDownLine[startX] = (
SChar)
sgn(srcLineBelow[startX] - srcLine[startX-1]);
454 signTmpLine = signUpLine;
455 signUpLine = signDownLine;
456 signDownLine = signTmpLine;
458 srcLine += srcStride;
459 resLine += resStride;
463 srcLineBelow= srcLine+ srcStride;
464 lastLineStartX = isBelowAvail ? startX : (width -1);
465 lastLineEndX = isBelowRightAvail ? width : (width -1);
466 for(x= lastLineStartX; x< lastLineEndX; x++)
468 edgeType =
sgn(srcLine[x] - srcLineBelow[x+ 1]) + signUpLine[x];
469 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
479 startX = isLeftAvail ? 0 : 1;
480 endX = isRightAvail ? width : (width -1);
483 Pel* srcLineBelow= srcLine+ srcStride;
484 for (x=startX-1; x< endX; x++)
486 signUpLine[x] = (
SChar)
sgn(srcLineBelow[x] - srcLine[x+1]);
491 Pel* srcLineAbove= srcLine- srcStride;
492 firstLineStartX = isAboveAvail ? startX : (width -1 );
493 firstLineEndX = isAboveRightAvail ? width : (width-1);
494 for(x= firstLineStartX; x< firstLineEndX; x++)
496 edgeType =
sgn(srcLine[x] - srcLineAbove[x+1]) -signUpLine[x-1];
497 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
499 srcLine += srcStride;
500 resLine += resStride;
503 for (y= 1; y< height-1; y++)
505 srcLineBelow= srcLine+ srcStride;
507 for(x= startX; x< endX; x++)
509 signDown = (
SChar)
sgn(srcLine[x] - srcLineBelow[x-1]);
510 edgeType = signDown + signUpLine[x];
511 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
512 signUpLine[x-1] = -signDown;
514 signUpLine[endX-1] = (
SChar)
sgn(srcLineBelow[endX-1] - srcLine[endX]);
515 srcLine += srcStride;
516 resLine += resStride;
520 srcLineBelow= srcLine+ srcStride;
521 lastLineStartX = isBelowLeftAvail ? 0 : 1;
522 lastLineEndX = isBelowAvail ? endX : 1;
523 for(x= lastLineStartX; x< lastLineEndX; x++)
525 edgeType =
sgn(srcLine[x] - srcLineBelow[x-1]) + signUpLine[x];
526 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[edgeType]);
534 for (y=0; y< height; y++)
536 for (x=0; x< width; x++)
538 resLine[x] = Clip3<Int>(0, maxSampleValueIncl, srcLine[x] + offset[srcLine[x] >> shiftBits] );
540 srcLine += srcStride;
541 resLine += resStride;
547 printf(
"Not a supported SAO types\n");
556 Bool isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail;
560 for(
Int compIdx = 0; compIdx < numberOfComponents; compIdx++)
580 for(
Int compIdx = 0; compIdx < numberOfComponents; compIdx++)
583 SAOOffset& ctbOffset = saoblkParam[compIdx];
590 Int blkWidth = (width >> componentScaleX);
591 Int blkHeight = (height >> componentScaleY);
592 Int blkXPos = (xPos >> componentScaleX);
593 Int blkYPos = (yPos >> componentScaleY);
596 Pel* srcBlk = srcYuv->
getAddr(component) + blkYPos*srcStride + blkXPos;
599 Pel* resBlk = resYuv->
getAddr(component) + blkYPos*resStride + blkXPos;
602 , srcBlk, resBlk, srcStride, resStride, blkWidth, blkHeight
603 , isLeftAvail, isRightAvail
604 , isAboveAvail, isBelowAvail
605 , isAboveLeftAvail, isAboveRightAvail
606 , isBelowLeftAvail, isBelowRightAvail
617 Bool bAllDisabled=
true;
618 for(
Int compIdx = 0; compIdx < numberOfComponents; compIdx++)
677 UInt uiQNumParts = uiCurNumParts>>2;
680 if( pcCU->
getDepth(uiAbsZorderIdx) > uiDepth )
682 for (
UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++, uiAbsZorderIdx+=uiQNumParts )
686 if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
698 for(
UInt comp=0; comp<numComponents; comp++)
714 UInt uiPcmLeftShiftBit;
718 const UInt uiOffset = (uiMinCoeffSize*uiAbsZorderIdx)>>(csx+csy);
729 uiPcmLeftShiftBit = 0;
736 for(
UInt uiY = 0; uiY < uiHeight; uiY++ )
738 for(
UInt uiX = 0; uiX < uiWidth; uiX++ )
740 piSrc[uiX] = (piPcm[uiX] << uiPcmLeftShiftBit);
Bool getPCMFilterDisableFlag() const
Void xPCMCURestoration(TComDataCU *pcCU, UInt uiAbsZorderIdx, UInt uiDepth)
sample adaptive offset class (header)
#define NUM_SAO_BO_CLASSES_LOG2
#define MAX_NUM_SAO_CLASSES
UInt getNumberOfCtusInFrame() const
picture class (symbol + YUV buffers)
Int getStride(const ComponentID id) const
TComSlice * getSlice(Int i)
UInt getNumPartitionsInCtu() const
ChromaFormat m_chromaFormatIDC
Bool m_picSAOEnabled[MAX_NUM_COMPONENT]
UInt getMaxCUHeight() const
Int getNumberValidComponents() const
Int getMergeList(TComPic *pic, Int ctuRsAddr, SAOBlkParam *blkParams, SAOBlkParam *mergeList[NUM_SAO_MERGE_TYPES])
Void invertQuantOffsets(ComponentID compIdx, Int typeIdc, Int typeAuxInfo, Int *dstOffsets, Int *srcOffsets)
Void reconstructBlkSAOParam(SAOBlkParam &recParam, SAOBlkParam *mergeList[NUM_SAO_MERGE_TYPES])
Bool getTransquantBypassEnabledFlag() const
UInt getMinCUWidth() const
TComPicYuv * m_tempPicYuv
TComPicYuv * getPicYuvRec()
Void xPCMSampleRestoration(TComDataCU *pcCU, UInt uiAbsZorderIdx, UInt uiDepth, const ComponentID compID)
Void offsetCTU(Int ctuRsAddr, TComPicYuv *srcYuv, TComPicYuv *resYuv, SAOBlkParam &saoblkParam, TComPic *pPic)
Void create(Int picWidth, Int picHeight, ChromaFormat format, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth, UInt lumaBitShift, UInt chromaBitShift)
UInt m_offsetStepLog2[MAX_NUM_COMPONENT]
SAOOffset offsetParam[MAX_NUM_COMPONENT]
#define NUM_SAO_BO_CLASSES
UInt getComponentScaleY(const ComponentID id) const
UInt getComponentScaleX(const ComponentID id) const
Bool getSAOMergeAvailability(Int currAddr, Int mergeAddr)
const SAOOffset & operator=(const SAOOffset &src)
Bool isLosslessCoded(UInt absPartIdx) const
UInt getMinCUHeight() const
Void copyToPic(TComPicYuv *pcPicYuvDst) const
Int getBitDepth(ChannelType type) const
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Void PCMLFDisableProcess(TComPic *pcPic)
UInt g_auiZscanToRaster[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
const TComPPS * getPPS() const
TComSampleAdaptiveOffset()
ChromaFormat getChromaFormat() const
const TComSPS & getSPS() const
const SAOBlkParam & operator=(const SAOBlkParam &src)
TComDataCU * getCtu(UInt ctuRsAddr)
Void SAOProcess(TComPic *pDecPic)
virtual ~TComSampleAdaptiveOffset()
Pel * getAddr(const ComponentID ch)
Void deriveLoopFilterBoundaryAvailibility(Int ctuRsAddr, Bool &isLeftAvail, Bool &isRightAvail, Bool &isAboveAvail, Bool &isBelowAvail, Bool &isAboveLeftAvail, Bool &isAboveRightAvail, Bool &isBelowLeftAvail, Bool &isBelowRightAvail)
Void create(const Int picWidth, const Int picHeight, const ChromaFormat chromaFormatIDC, const UInt maxCUWidth, const UInt maxCUHeight, const UInt maxCUDepth, const Bool bUseMargin)
if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image...
UInt getPCMBitDepth(ChannelType type) const
Void offsetBlock(const Int channelBitDepth, Int typeIdx, Int *offset, Pel *srcBlk, Pel *resBlk, Int srcStride, Int resStride, Int width, Int height, Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail)
Void reconstructBlkSAOParams(TComPic *pic, SAOBlkParam *saoBlkParams)
Pel * getPCMSample(ComponentID component)
UInt g_auiRasterToPelX[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
UInt g_auiRasterToPelY[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
UInt getMaxCUWidth() const
Void xPCMRestoration(TComPic *pcPic)
const TComSPS * getSPS() const
SAOBlkParam * getSAOBlkParam()