📄 pp.c
字号:
DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); } } else if(Variance > Thresh2 ) { DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); } else if(Variance > Thresh1 ) { DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); } else { dsp_copy8x8(pbi->dsp, SrcPtr + 8 * col, DestPtr + 8 * col, LineLength); } ++Block; } SrcPtr += 8 * LineLength; DestPtr += 8 * LineLength; } /* Then U */ BlocksAcross /= 2; BlocksDown /= 2; LineLength /= 2; SrcPtr = Src + pbi->ReconUDataOffset; DestPtr = Dst + pbi->ReconUDataOffset; for ( row = 0 ; row < BlocksDown; row ++) { for (col = 0; col < BlocksAcross; col ++) { ogg_uint32_t Quality = pbi->FragQIndex[Block]; ogg_int32_t Variance = pbi->FragmentVariances[Block]; if( pbi->PostProcessingLevel >5 && Variance > Thresh4 ) { DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); }else if(Variance > Thresh2 ){ DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); }else if(Variance > Thresh1 ){ DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); }else{ dsp_copy8x8(pbi->dsp, SrcPtr + 8 * col, DestPtr + 8 * col, LineLength); } ++Block; } SrcPtr += 8 * LineLength; DestPtr += 8 * LineLength; } /* Then V */ SrcPtr = Src + pbi->ReconVDataOffset; DestPtr = Dst + pbi->ReconVDataOffset; for ( row = 0 ; row < BlocksDown; row ++){ for (col = 0; col < BlocksAcross; col ++){ ogg_uint32_t Quality = pbi->FragQIndex[Block]; ogg_int32_t Variance = pbi->FragmentVariances[Block]; if( pbi->PostProcessingLevel >5 && Variance > Thresh4 ) { DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); }else if(Variance > Thresh2 ){ DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); }else if(Variance > Thresh1 ){ DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength,Quality,QuantScale); }else{ dsp_copy8x8(pbi->dsp, SrcPtr + 8 * col, DestPtr + 8 * col, LineLength); } ++Block; } SrcPtr += 8 * LineLength; DestPtr += 8 * LineLength; }}void UpdateFragQIndex(PB_INSTANCE *pbi){ ogg_uint32_t ThisFrameQIndex; ogg_uint32_t i; /* Check this frame quality index */ ThisFrameQIndex = pbi->FrameQIndex; /* It is not a key frame, so only reset those are coded */ for( i = 0; i < pbi->UnitFragments; i++ ) if( pbi->display_fragments[i]) pbi->FragQIndex[i] = ThisFrameQIndex;}static void DeblockLoopFilteredBand(PB_INSTANCE *pbi, unsigned char *SrcPtr, unsigned char *DesPtr, ogg_uint32_t PlaneLineStep, ogg_uint32_t FragsAcross, ogg_uint32_t StartFrag, const ogg_uint32_t *QuantScale){ ogg_uint32_t j,k; ogg_uint32_t CurrentFrag=StartFrag; ogg_int32_t QStep; ogg_int32_t FLimit; unsigned char *Src, *Des; ogg_int32_t x[10]; ogg_int32_t Sum1, Sum2; while(CurrentFrag < StartFrag + FragsAcross){ Src=SrcPtr+8*(CurrentFrag-StartFrag)-PlaneLineStep*5; Des=DesPtr+8*(CurrentFrag-StartFrag)-PlaneLineStep*4; QStep = QuantScale[pbi->FragQIndex[CurrentFrag+FragsAcross]]; FLimit = ( QStep * 3 ) >> 2; for( j=0; j<8 ; j++){ x[0] = Src[0]; x[1] = Src[PlaneLineStep]; x[2] = Src[PlaneLineStep*2]; x[3] = Src[PlaneLineStep*3]; x[4] = Src[PlaneLineStep*4]; x[5] = Src[PlaneLineStep*5]; x[6] = Src[PlaneLineStep*6]; x[7] = Src[PlaneLineStep*7]; x[8] = Src[PlaneLineStep*8]; x[9] = Src[PlaneLineStep*9]; Sum1=Sum2=0; for(k=1;k<=4;k++){ Sum1 += abs(x[k]-x[k-1]); Sum2 += abs(x[k+4]-x[k+5]); } pbi->FragmentVariances[CurrentFrag] +=((Sum1>255)?255:Sum1); pbi->FragmentVariances[CurrentFrag + FragsAcross] += ((Sum2>255)?255:Sum2); if( Sum1 < FLimit && Sum2 < FLimit && (x[5] - x[4]) < QStep && (x[4] - x[5]) < QStep ){ /* low pass filtering (LPF7: 1 1 1 2 1 1 1) */ Des[0 ] = (x[0] + x[0] +x[0] + x[1] * 2 + x[2] + x[3] +x[4] + 4) >> 3; Des[PlaneLineStep ] = (x[0] + x[0] +x[1] + x[2] * 2 + x[3] + x[4] +x[5] + 4) >> 3; Des[PlaneLineStep*2] = (x[0] + x[1] +x[2] + x[3] * 2 + x[4] + x[5] +x[6] + 4) >> 3; Des[PlaneLineStep*3] = (x[1] + x[2] +x[3] + x[4] * 2 + x[5] + x[6] +x[7] + 4) >> 3; Des[PlaneLineStep*4] = (x[2] + x[3] +x[4] + x[5] * 2 + x[6] + x[7] +x[8] + 4) >> 3; Des[PlaneLineStep*5] = (x[3] + x[4] +x[5] + x[6] * 2 + x[7] + x[8] +x[9] + 4) >> 3; Des[PlaneLineStep*6] = (x[4] + x[5] +x[6] + x[7] * 2 + x[8] + x[9] +x[9] + 4) >> 3; Des[PlaneLineStep*7] = (x[5] + x[6] +x[7] + x[8] * 2 + x[9] + x[9] +x[9] + 4) >> 3; }else { /* copy the pixels to destination */ Des[0 ]= (unsigned char)x[1]; Des[PlaneLineStep ]= (unsigned char)x[2]; Des[PlaneLineStep*2]= (unsigned char)x[3]; Des[PlaneLineStep*3]= (unsigned char)x[4]; Des[PlaneLineStep*4]= (unsigned char)x[5]; Des[PlaneLineStep*5]= (unsigned char)x[6]; Des[PlaneLineStep*6]= (unsigned char)x[7]; Des[PlaneLineStep*7]= (unsigned char)x[8]; } Src ++; Des ++; } /* done with filtering the horizontal edge, now let's do the vertical one */ /* skip the first one */ if(CurrentFrag==StartFrag) CurrentFrag++; else{ Des=DesPtr-8*PlaneLineStep+8*(CurrentFrag-StartFrag); Src=Des-5; Des-=4; QStep = QuantScale[pbi->FragQIndex[CurrentFrag]]; FLimit = ( QStep * 3 ) >> 2; for( j=0; j<8 ; j++){ x[0] = Src[0]; x[1] = Src[1]; x[2] = Src[2]; x[3] = Src[3]; x[4] = Src[4]; x[5] = Src[5]; x[6] = Src[6]; x[7] = Src[7]; x[8] = Src[8]; x[9] = Src[9]; Sum1=Sum2=0; for(k=1;k<=4;k++){ Sum1 += abs(x[k]-x[k-1]); Sum2 += abs(x[k+4]-x[k+5]); } pbi->FragmentVariances[CurrentFrag-1] += ((Sum1>255)?255:Sum1); pbi->FragmentVariances[CurrentFrag] += ((Sum2>255)?255:Sum2); if( Sum1 < FLimit && Sum2 < FLimit && (x[5] - x[4]) < QStep && (x[4] - x[5]) < QStep ){ /* low pass filtering (LPF7: 1 1 1 2 1 1 1) */ Des[0] = (x[0] + x[0] +x[0] + x[1] * 2 + x[2] + x[3] +x[4] + 4) >> 3; Des[1] = (x[0] + x[0] +x[1] + x[2] * 2 + x[3] + x[4] +x[5] + 4) >> 3; Des[2] = (x[0] + x[1] +x[2] + x[3] * 2 + x[4] + x[5] +x[6] + 4) >> 3; Des[3] = (x[1] + x[2] +x[3] + x[4] * 2 + x[5] + x[6] +x[7] + 4) >> 3; Des[4] = (x[2] + x[3] +x[4] + x[5] * 2 + x[6] + x[7] +x[8] + 4) >> 3; Des[5] = (x[3] + x[4] +x[5] + x[6] * 2 + x[7] + x[8] +x[9] + 4) >> 3; Des[6] = (x[4] + x[5] +x[6] + x[7] * 2 + x[8] + x[9] +x[9] + 4) >> 3; Des[7] = (x[5] + x[6] +x[7] + x[8] * 2 + x[9] + x[9] +x[9] + 4) >> 3; } Src += PlaneLineStep; Des += PlaneLineStep; } CurrentFrag ++; } }}static void DeblockVerticalEdgesInLoopFilteredBand(PB_INSTANCE *pbi, unsigned char *SrcPtr, unsigned char *DesPtr, ogg_uint32_t PlaneLineStep, ogg_uint32_t FragsAcross, ogg_uint32_t StartFrag, const ogg_uint32_t *QuantScale){ ogg_uint32_t j,k; ogg_uint32_t CurrentFrag=StartFrag; ogg_int32_t QStep; ogg_int32_t FLimit; unsigned char *Src, *Des; ogg_int32_t x[10]; ogg_int32_t Sum1, Sum2; while(CurrentFrag < StartFrag + FragsAcross-1) { Src=SrcPtr+8*(CurrentFrag-StartFrag+1)-5; Des=DesPtr+8*(CurrentFrag-StartFrag+1)-4; QStep = QuantScale[pbi->FragQIndex[CurrentFrag+1]]; FLimit = ( QStep * 3)>>2 ; for( j=0; j<8 ; j++){ x[0] = Src[0]; x[1] = Src[1]; x[2] = Src[2]; x[3] = Src[3]; x[4] = Src[4]; x[5] = Src[5]; x[6] = Src[6]; x[7] = Src[7]; x[8] = Src[8]; x[9] = Src[9]; Sum1=Sum2=0; for(k=1;k<=4;k++){ Sum1 += abs(x[k]-x[k-1]); Sum2 += abs(x[k+4]-x[k+5]); } pbi->FragmentVariances[CurrentFrag] += ((Sum1>255)?255:Sum1); pbi->FragmentVariances[CurrentFrag+1] += ((Sum2>255)?255:Sum2); if( Sum1 < FLimit && Sum2 < FLimit && (x[5] - x[4]) < QStep && (x[4] - x[5]) < QStep ){ /* low pass filtering (LPF7: 1 1 1 2 1 1 1) */ Des[0] = (x[0] + x[0] +x[0] + x[1] * 2 + x[2] + x[3] +x[4] + 4) >> 3; Des[1] = (x[0] + x[0] +x[1] + x[2] * 2 + x[3] + x[4] +x[5] + 4) >> 3; Des[2] = (x[0] + x[1] +x[2] + x[3] * 2 + x[4] + x[5] +x[6] + 4) >> 3; Des[3] = (x[1] + x[2] +x[3] + x[4] * 2 + x[5] + x[6] +x[7] + 4) >> 3; Des[4] = (x[2] + x[3] +x[4] + x[5] * 2 + x[6] + x[7] +x[8] + 4) >> 3; Des[5] = (x[3] + x[4] +x[5] + x[6] * 2 + x[7] + x[8] +x[9] + 4) >> 3; Des[6] = (x[4] + x[5] +x[6] + x[7] * 2 + x[8] + x[9] +x[9] + 4) >> 3; Des[7] = (x[5] + x[6] +x[7] + x[8] * 2 + x[9] + x[9] +x[9] + 4) >> 3; } Src +=PlaneLineStep; Des +=PlaneLineStep; } CurrentFrag ++; }}static void DeblockPlane(PB_INSTANCE *pbi, unsigned char *SourceBuffer, unsigned char *DestinationBuffer, ogg_uint32_t Channel ){ ogg_uint32_t i,k; ogg_uint32_t PlaneLineStep=0; ogg_uint32_t StartFrag =0; ogg_uint32_t PixelIndex=0; unsigned char * SrcPtr=0, * DesPtr=0; ogg_uint32_t FragsAcross=0; ogg_uint32_t FragsDown=0; const ogg_uint32_t *QuantScale=0; switch( Channel ){ case 0: /* Get the parameters */ PlaneLineStep = pbi->YStride; FragsAcross = pbi->HFragments; FragsDown = pbi->VFragments; StartFrag = 0; PixelIndex = pbi->ReconYDataOffset; SrcPtr = & SourceBuffer[PixelIndex]; DesPtr = & DestinationBuffer[PixelIndex]; break; case 1: /* Get the parameters */ PlaneLineStep = pbi->UVStride; FragsAcross = pbi->HFragments / 2; FragsDown = pbi->VFragments / 2; StartFrag = pbi->YPlaneFragments; PixelIndex = pbi->ReconUDataOffset; SrcPtr = & SourceBuffer[PixelIndex]; DesPtr = & DestinationBuffer[PixelIndex]; break; default: /* Get the parameters */ PlaneLineStep = pbi->UVStride; FragsAcross = pbi->HFragments / 2; FragsDown = pbi->VFragments / 2; StartFrag = pbi->YPlaneFragments + pbi->UVPlaneFragments; PixelIndex = pbi->ReconVDataOffset; SrcPtr = & SourceBuffer[PixelIndex]; DesPtr = & DestinationBuffer[PixelIndex]; break; } QuantScale = DcQuantScaleV1; for(i=0;i<4;i++) memcpy(DesPtr+i*PlaneLineStep, SrcPtr+i*PlaneLineStep, PlaneLineStep); k = 1; while( k < FragsDown ){ SrcPtr += 8*PlaneLineStep; DesPtr += 8*PlaneLineStep; /* Filter both the horizontal and vertical block edges inside the band */ DeblockLoopFilteredBand(pbi, SrcPtr, DesPtr, PlaneLineStep, FragsAcross, StartFrag, QuantScale); /* Move Pointers */ StartFrag += FragsAcross; k ++; } /* The Last band */ for(i=0;i<4;i++) memcpy(DesPtr+(i+4)*PlaneLineStep, SrcPtr+(i+4)*PlaneLineStep, PlaneLineStep); DeblockVerticalEdgesInLoopFilteredBand(pbi,SrcPtr,DesPtr,PlaneLineStep, FragsAcross,StartFrag,QuantScale);}static void DeblockFrame(PB_INSTANCE *pbi, unsigned char *SourceBuffer, unsigned char *DestinationBuffer){ memset(pbi->FragmentVariances, 0 , sizeof(ogg_int32_t) * pbi->UnitFragments); UpdateFragQIndex(pbi); SetupLoopFilter(pbi); /* Y */ DeblockPlane( pbi, SourceBuffer, DestinationBuffer, 0); /* U */ DeblockPlane( pbi, SourceBuffer, DestinationBuffer, 1); /* V */ DeblockPlane( pbi, SourceBuffer, DestinationBuffer, 2);}void PostProcess(PB_INSTANCE *pbi){ switch (pbi->PostProcessingLevel){ case 8: /* on a slow machine, use a simpler and faster deblocking filter */ DeblockFrame(pbi, pbi->LastFrameRecon,pbi->PostProcessBuffer); break; case 6: DeblockFrame(pbi, pbi->LastFrameRecon,pbi->PostProcessBuffer); UpdateUMVBorder(pbi, pbi->PostProcessBuffer ); DeringFrame(pbi, pbi->PostProcessBuffer, pbi->PostProcessBuffer); break; case 5: DeblockFrame(pbi, pbi->LastFrameRecon,pbi->PostProcessBuffer); UpdateUMVBorder(pbi, pbi->PostProcessBuffer ); DeringFrame(pbi, pbi->PostProcessBuffer, pbi->PostProcessBuffer); break; case 4: DeblockFrame(pbi, pbi->LastFrameRecon, pbi->PostProcessBuffer); break; case 1: UpdateFragQIndex(pbi); break; case 0: break; default: DeblockFrame(pbi, pbi->LastFrameRecon, pbi->PostProcessBuffer); UpdateUMVBorder(pbi, pbi->PostProcessBuffer ); DeringFrame(pbi, pbi->PostProcessBuffer, pbi->PostProcessBuffer); break; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -