📄 umc_vc1_dec_mb_interpolate_com.cpp
字号:
/* /////////////////////////////////////////////////////////////////////////////
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2004-2007 Intel Corporation. All Rights Reserved.
//
//
// VC-1 (VC1) decoder, MB Layer common for simple\main profiles
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_VC1_VIDEO_DECODER)
#include "umc_vc1_dec_seq.h"
#include "umc_vc1_dec_debug.h"
#include "umc_vc1_common_defs.h"
#include "umc_vc1_common_blk_order_tbl.h"
static const Ipp8u esbp_lut[] = {1,2,2,2,4,4,4,8};
#ifdef _OWN_FUNCTION
#define CLIP(x) (!(x&~255)?x:(x<0?0:255))
static const int BicubicFilterParams[4][4] =
{
{-4, 53, 18, -3}, // 1/4
{-1, 9, 9, -1}, // 1/2
{-3, 18, 53, -4} // 3/4
};
static const char BicubicVertFilterShift[4][3] =
{
{6, 4, 6},
{5, 3, 5},
{3, 1, 3},
{5, 3, 5}
};
static const char BicubicHorizFilterShift[3][4] =
{
{6, 7, 7, 7},
{4, 7, 7, 7},
{6, 7, 7, 7}
};
typedef IppStatus (*ippiBicubicInterpolate) (const Ipp8u* pSrc,
Ipp32s srcStep,
Ipp8u *pDst,
Ipp32s dstStep,
Ipp32s dx,
Ipp32s dy,
Ipp32s roundControl);
static IppStatus ippiInterpolate16x16QPBicubicIC_VC1_8u_C1R (const Ipp8u* pSrc,
Ipp32s srcStep,
Ipp8u *pDst,
Ipp32s dstStep,
Ipp32s dx,
Ipp32s dy,
Ipp32s roundControl)
{
IppStatus ret = ippStsNoErr;
unsigned choose_int = ( (1==(0==(dx))) |(((1==(0 == (dy))) << 1)));
short TempBlock[(17 + 3) * 17];
int i, j;
int PBPL = 17 + 3;
int R = roundControl;
short *pDst16 = TempBlock + 1;
short *pSource16 = TempBlock + 1;
int Pixel;
int Fy0, Fy1, Fy2, Fy3;
int Fx0, Fx1, Fx2, Fx3;
const int (*FP) = BicubicFilterParams[(dy) - 1];
int Abs, Shift;
Fy0 = FP[0];
Fy1 = FP[1];
Fy2 = FP[2];
Fy3 = FP[3];
FP = BicubicFilterParams[dx - 1];
Fx0 = FP[0];
Fx1 = FP[1];
Fx2 = FP[2];
Fx3 = FP[3];
switch(choose_int)
{
case 0:
Shift = BicubicVertFilterShift[(dx)][(dy) - 1];
Abs = 1 << (Shift - 1);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("PelBicubicDiag\n") );
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d\t %d\t %d\n"),*pSource,X>>2,Y>>2);
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("Source\n" ));
// for(j = -1; j < 16+2; j++)
// {
// for(i = -1; i < 16+2; i++)
// {
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pSrc[i + j*srcStep]);
// }
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n"));
// }
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("F(%d, %d, %d, %d) abs=%d r=%d shift=%d\n") ,Fy0,Fy1,Fy2,Fy3,Abs,R,Shift);
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("after interpolate\n") );
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n"));
#endif
/* vertical filter */
for(j = 0; j < 16; j++)
{
for(i = -1; i < 3; i++)
{
Pixel = ((pSrc[i - srcStep] * Fy0 +
pSrc[i] * Fy1 +
pSrc[i + srcStep] * Fy2 +
pSrc[i + 2*srcStep]* Fy3 +
Abs - 1 + R) >> Shift);
pDst16[i] = (short)Pixel;
}
for(;i < 16+2; i++)
{
Pixel = ((pSrc[i - srcStep] * Fy0 +
pSrc[i] * Fy1 +
pSrc[i + srcStep] * Fy2 +
pSrc[i + 2*srcStep]* Fy3 +
Abs - 1 + R) >> Shift);
pDst16[i] = (short)Pixel;
pDst[i-3] = CLIP((pDst16[i-4] * Fx0 +
pDst16[i-3] * Fx1 +
pDst16[i-2] * Fx2 +
pDst16[i-1] * Fx3 + 64 - R) >> 7);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i-3] );
#endif
}
pDst[i-3] = CLIP((pDst16[i-4] * Fx0 +
pDst16[i-3] * Fx1 +
pDst16[i-2] * Fx2 +
pDst16[i-1] * Fx3 + 64 - R) >> 7);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i-3] );
#endif
pDst += dstStep;
pSrc += srcStep;
pDst16 += PBPL;
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n") );
#endif
}
break;
case 1:
Shift = BicubicVertFilterShift[0][(dy) - 1];
Abs = 1 << (Shift - 1);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("PelBicubicVert\n") );
#endif
for(j = 0; j < 16; j++)
{
for(i = 0; i < 16; i++)
{
pDst[i] = CLIP((pSrc[i - srcStep] * Fy0 +
pSrc[i] * Fy1 +
pSrc[i + srcStep] * Fy2 +
pSrc[i + 2*srcStep] * Fy3 +
Abs - 1 + R) >> Shift);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i] );
#endif
}
pSrc += srcStep;
pDst += dstStep;
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n") );
#endif
}
break;
case 2:
Shift = BicubicHorizFilterShift[(dx) - 1][0];
Abs = 1 << (Shift - 1);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("PelBicubicHoriz\n") );
#endif
for(j = 0; j < 16; j++)
{
for(i = 0; i < 16; i++)
{
pDst[i] = CLIP((pSrc[i-1] * Fx0 +
pSrc[i] * Fx1 +
pSrc[i+1] * Fx2 +
pSrc[i + 2] * Fx3 +
Abs - R) >> Shift);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i] );
#endif
}
pSrc += srcStep;
pDst += dstStep;
//VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n") );
}
break;
case 3:
for(j = 0; j < 16; j++)
{
for(i = 0; i < 16; i++)
{
pDst[i] = pSrc[i];
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i] );
#endif
}
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n") );
#endif
pSrc += srcStep;
pDst += dstStep;
}
break;
default:
break;
}
return ret;
}
static IppStatus ippiInterpolate16x8QPBicubicIC_VC1_8u_C1R (const Ipp8u* pSrc,
Ipp32s srcStep,
Ipp8u *pDst,
Ipp32s dstStep,
Ipp32s dx,
Ipp32s dy,
Ipp32s roundControl)
{
IppStatus ret = ippStsNoErr;
unsigned choose_int = ( (1==(0==(dx))) |(((1==(0 == (dy))) << 1)));
static unsigned inter_flag = 0;
short TempBlock[(17 + 3) * 17];
int i, j;
int PBPL = 17 + 3;
int R = roundControl;
short *pDst16 = TempBlock + 1;
short *pSource16 = TempBlock + 1;
int Pixel;
int Fy0, Fy1, Fy2, Fy3;
int Fx0, Fx1, Fx2, Fx3;
const int (*FP) = BicubicFilterParams[(dy) - 1];
int Abs, Shift;
Fy0 = FP[0];
Fy1 = FP[1];
Fy2 = FP[2];
Fy3 = FP[3];
FP = BicubicFilterParams[dx - 1];
Fx0 = FP[0];
Fx1 = FP[1];
Fx2 = FP[2];
Fx3 = FP[3];
switch(choose_int)
{
case 0:
Shift = BicubicVertFilterShift[(dx)][(dy) - 1];
Abs = 1 << (Shift - 1);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("PelBicubicDiag\n") );
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d\t %d\t %d\n"),*pSource,X>>2,Y>>2);
//VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("Source\n" ));
// for(j = -1; j < 8+2; j++)
// {
// for(i = -1; i < 16+2; i++)
//{
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pSrc[i + j*srcStep]);
// }
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n"));
// }
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("F(%d, %d, %d, %d) abs=%d r=%d shift=%d\n") ,Fy0,Fy1,Fy2,Fy3,Abs,R,Shift);
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("after interpolate\n") );
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n"));
#endif
/* vertical filter */
for(j = 0; j < 8; j++)
{
for(i = -1; i < 3; i++)
{
Pixel = ((pSrc[i - srcStep] * Fy0 +
pSrc[i] * Fy1 +
pSrc[i + srcStep] * Fy2 +
pSrc[i + 2*srcStep]* Fy3 +
Abs - 1 + R) >> Shift);
pDst16[i] = (short)Pixel;
}
for(;i < 16+2; i++)
{
Pixel = ((pSrc[i - srcStep] * Fy0 +
pSrc[i] * Fy1 +
pSrc[i + srcStep] * Fy2 +
pSrc[i + 2*srcStep]* Fy3 +
Abs - 1 + R) >> Shift);
pDst16[i] = (short)Pixel;
pDst[i-3] = CLIP((pDst16[i-4] * Fx0 +
pDst16[i-3] * Fx1 +
pDst16[i-2] * Fx2 +
pDst16[i-1] * Fx3 + 64 - R) >> 7);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i-3] );
#endif
}
pDst[i-3] = CLIP((pDst16[i-4] * Fx0 +
pDst16[i-3] * Fx1 +
pDst16[i-2] * Fx2 +
pDst16[i-1] * Fx3 + 64 - R) >> 7);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i-3] );
#endif
pDst += dstStep;
pSrc += srcStep;
pDst16 += PBPL;
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n") );
#endif
}
break;
case 1:
Shift = BicubicVertFilterShift[0][(dy) - 1];
Abs = 1 << (Shift - 1);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("PelBicubicVert\n") );
#endif
for(j = 0; j < 8; j++)
{
for(i = 0; i < 16; i++)
{
pDst[i] = CLIP((pSrc[i - srcStep] * Fy0 +
pSrc[i] * Fy1 +
pSrc[i + srcStep] * Fy2 +
pSrc[i + 2*srcStep] * Fy3 +
Abs - 1 + R) >> Shift);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i] );
#endif
}
pSrc += srcStep;
pDst += dstStep;
#ifdef VC1_DEBUG_ON
//VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("\n") );
#endif
}
break;
case 2:
Shift = BicubicHorizFilterShift[(dx) - 1][0];
Abs = 1 << (Shift - 1);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("PelBicubicHoriz\n") );
#endif
for(j = 0; j < 8; j++)
{
for(i = 0; i < 16; i++)
{
pDst[i] = CLIP((pSrc[i-1] * Fx0 +
pSrc[i] * Fx1 +
pSrc[i+1] * Fx2 +
pSrc[i + 2] * Fx3 +
Abs - R) >> Shift);
#ifdef VC1_DEBUG_ON
// VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%d "), pDst[i] );
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -