?? skl_mpg4_anl.cpp
字號:
case 8: Ops->V_Pass_8(Dst, Src, 16, 2*BpS); break; case 9: Ops->H_Pass_Avrg(YTmp, Src, 9, 2*BpS); Ops->V_Pass_8(Dst, YTmp, 16, 2*BpS); break; case 10: Ops->H_Pass(YTmp, Src, 9, 2*BpS); Ops->V_Pass_8(Dst, YTmp, 16, 2*BpS); break; case 11: Ops->H_Pass_Avrg_Up(YTmp, Src, 9, 2*BpS); Ops->V_Pass_8(Dst, YTmp, 16, 2*BpS); break; case 12: Ops->V_Pass_Avrg_Up_8(Dst, Src, 16, 2*BpS); break; case 13: Ops->H_Pass_Avrg(YTmp, Src, 9, 2*BpS); Ops->V_Pass_Avrg_Up_8(Dst, YTmp, 16, 2*BpS); break; case 14: Ops->H_Pass(YTmp, Src, 9, 2*BpS); Ops->V_Pass_Avrg_Up_8( Dst, YTmp, 16, 2*BpS); break; case 15: Ops->H_Pass_Avrg_Up(YTmp, Src, 9, 2*BpS); Ops->V_Pass_Avrg_Up_8(Dst, YTmp, 16, 2*BpS); break; }}static void Predict_8x8_QP(SKL_BYTE * const Dst, const SKL_BYTE *Src, SKL_BYTE * const YTmp, // <- 9x16 buffer const int x, const int y, const int BpS, const SKL_MB_FUNCS * const Ops){ const int Quads = (x&3) | ((y&3)<<2); Src += (y>>2)*BpS + (x>>2); switch(Quads) { default: case 0: Ops->HP_8x8[0](Dst, Src, BpS); break; case 1: Ops->H_Pass_Avrg_8(Dst, Src, 8, BpS); break; case 2: Ops->H_Pass_8(Dst, Src, 8, BpS); break; case 3: Ops->H_Pass_Avrg_Up_8(Dst, Src, 8, BpS); break; case 4: Ops->V_Pass_Avrg_8(Dst, Src, 8, BpS); break; case 5: Ops->H_LowPass_Avrg_8(YTmp, Src, 9, BpS); Ops->V_Pass_Avrg_8(Dst, YTmp, 8, BpS); break; case 6: Ops->H_LowPass_8(YTmp, Src, 9, BpS); Ops->V_Pass_Avrg_8(Dst, YTmp, 8, BpS); break; case 7: Ops->H_LowPass_Avrg_Up_8(YTmp, Src, 9, BpS); Ops->V_Pass_Avrg_8(Dst, YTmp, 8, BpS); break; case 8: Ops->V_Pass_8(Dst, Src, 8, BpS); break; case 9: Ops->H_LowPass_Avrg_8(YTmp, Src, 9, BpS); Ops->V_Pass_8(Dst, YTmp, 8, BpS); break; case 10: Ops->H_LowPass_8(YTmp, Src, 9, BpS); Ops->V_Pass_8(Dst, YTmp, 8, BpS); break; case 11: Ops->H_LowPass_Avrg_Up_8(YTmp, Src, 9, BpS); Ops->V_Pass_8(Dst, YTmp, 8, BpS); break; case 12: Ops->V_Pass_Avrg_Up_8(Dst, Src, 8, BpS); break; case 13: Ops->H_LowPass_Avrg_8(YTmp, Src, 9, BpS); Ops->V_Pass_Avrg_Up_8(Dst, YTmp, 8, BpS); break; case 14: Ops->H_LowPass_8(YTmp, Src, 9, BpS); Ops->V_Pass_Avrg_Up_8( Dst, YTmp, 8, BpS); break; case 15: Ops->H_LowPass_Avrg_Up_8(YTmp, Src, 9, BpS); Ops->V_Pass_Avrg_Up_8(Dst, YTmp, 8, BpS); break; }}#define GET_HP_SAD(Ref,dx,dy) \ Funcs[dx+dy*2](Scratch2, Ref, BpS); \ Funcs[dx+dy*2](Scratch2+8*BpS, Ref+8*BpS, BpS); \ Sad = Metric(Src,Scratch2,BpS)#define GET_QP_SAD(x, y) \ Predict_16x16_QP(Scratch2, Ref, Scratch1, (x), (y), BpS, Funcs); \ Sad = Metric(Src,Scratch2,BpS) + MV_Bits_Cost_Raw((x),(y))#define REFINE_METHOD Refine_MV_16x16#define FUNC_NAME HP_16x8#define BPS BpS#include "./skl_mpg4_anl.cpp"#define GET_HP_SAD(Ref,dx,dy) \ Funcs[dx+dy*2](Scratch2, Ref, BpS); \ Sad = Metric(Src,Scratch2,BpS)#define GET_QP_SAD(x, y) \ Predict_8x8_QP(Scratch2, Ref, Scratch1, (x), (y), BpS, Funcs); \ Sad = Metric(Src,Scratch2,BpS) + MV_Bits_Cost_Raw((x),(y))#define REFINE_METHOD Refine_MV_8x8#define FUNC_NAME HP_8x8#define BPS BpS#include "./skl_mpg4_anl.cpp"#define GET_HP_SAD(Ref,dx,dy) \ Funcs[dx+dy*2](Scratch2, Ref, 2*BpS); \ Sad = Metric(Src,Scratch2,2*BpS)#define GET_QP_SAD(x, y) \ Predict_16x8_Field_QP(Scratch2, Ref, Scratch1, (x), (y), BpS, Funcs); \ Sad = Metric(Src,Scratch2,2*BpS) + MV_Bits_Cost_Raw((x),(y))#define REFINE_METHOD Refine_MV_16x8#define FUNC_NAME HP_16x8#define BPS 2*BpS#include "./skl_mpg4_anl.cpp"#undef SKL_AUTO_INCLUDE#endif /* !SKL_AUTO_INCLUDE *///////////////////////////////////////////////////////////#ifdef SKL_AUTO_INCLUDESKL_UINT32 ME_MAP::REFINE_METHOD(SKL_MV MV, const int Prec, const int Rounding){ MV[0] = Best_MV[0] << 1; MV[1] = Best_MV[1] << 1; if (Prec==0) return Best_Sad; const SKL_BYTE *Rf = Ref + Best_MV[0] + Best_MV[1]*BpS; // input MV is FULL pel SKL_UINT32 Sad0 = Best_Sad; SKL_UINT32 Sad; int dx = 0, dy = 0; if (Prec==1) { const int x = MV[0]; const int y = MV[1]; const SKL_MB_FUNC * const Funcs = Frame->MB_Dsp->Copy[Rounding]->FUNC_NAME; GET_HP_SAD( Rf-1, 1,0 ); Sad += MV_Bits_Cost_Raw(x-1, y); if (Sad<Sad0) { Sad0 = Sad; dx=-1; dy=0; } GET_HP_SAD( Rf, 1,0 ); Sad += MV_Bits_Cost_Raw(x+1, y); if (Sad<Sad0) { Sad0 = Sad; dx=1; dy=0; } GET_HP_SAD( Rf-BPS, 0,1 ); Sad += MV_Bits_Cost_Raw(x, y-1); if (Sad<Sad0) { Sad0 = Sad; dx=0; dy=-1; } GET_HP_SAD( Rf, 0,1 ); Sad += MV_Bits_Cost_Raw(x, y+1); if (Sad<Sad0) { Sad0 = Sad; dx=0; dy=1; } GET_HP_SAD( Rf-1-BPS, 1,1 ); Sad += MV_Bits_Cost_Raw(x-1, y-1); if (Sad<Sad0) { Sad0 = Sad; dx=-1; dy=-1; } GET_HP_SAD( Rf, 1,1 ); Sad += MV_Bits_Cost_Raw(x+1, y+1); if (Sad<Sad0) { Sad0 = Sad; dx= 1; dy= 1; } GET_HP_SAD( Rf-BPS, 1,1 ); Sad += MV_Bits_Cost_Raw(x+1, y-1); if (Sad<Sad0) { Sad0 = Sad; dx=1; dy=-1; } GET_HP_SAD( Rf-1, 1,1 ); Sad += MV_Bits_Cost_Raw(x-1, y+1); if (Sad<Sad0) { Sad0 = Sad; dx=-1; dy=1; } MV[0] += dx; MV[1] += dy; } else { const SKL_MB_FUNCS * const Funcs = Frame->MB_Dsp->Copy[Rounding]; int x = Best_MV[0] << 2; int y = Best_MV[1] << 2; int dx = 0, dy = 0; GET_QP_SAD(x-2, y+0); if (Sad<Sad0) { Sad0 = Sad; dx=-2; dy= 0; } GET_QP_SAD(x+2, y+0); if (Sad<Sad0) { Sad0 = Sad; dx= 2; dy= 0; } GET_QP_SAD(x , y-2); if (Sad<Sad0) { Sad0 = Sad; dx= 0; dy=-2; } GET_QP_SAD(x , y+2); if (Sad<Sad0) { Sad0 = Sad; dx= 0; dy= 2; } GET_QP_SAD(x-2, y-2); if (Sad<Sad0) { Sad0 = Sad; dx=-2; dy=-2; } GET_QP_SAD(x-2, y+2); if (Sad<Sad0) { Sad0 = Sad; dx=-2; dy= 2; } GET_QP_SAD(x+2, y-2); if (Sad<Sad0) { Sad0 = Sad; dx= 2; dy=-2; } GET_QP_SAD(x+2, y+2); if (Sad<Sad0) { Sad0 = Sad; dx= 2; dy= 2; } x += dx; y += dy; dx = 0; dy = 0; GET_QP_SAD(x-1, y+0); if (Sad<Sad0) { Sad0 = Sad; dx=-1; dy= 0; } GET_QP_SAD(x+1, y+0); if (Sad<Sad0) { Sad0 = Sad; dx= 1; dy= 0; } GET_QP_SAD(x , y-1); if (Sad<Sad0) { Sad0 = Sad; dx= 0; dy=-1; } GET_QP_SAD(x , y+1); if (Sad<Sad0) { Sad0 = Sad; dx= 0; dy= 1; } GET_QP_SAD(x-1, y-1); if (Sad<Sad0) { Sad0 = Sad; dx=-1; dy=-1; } GET_QP_SAD(x-1, y+1); if (Sad<Sad0) { Sad0 = Sad; dx=-1; dy= 1; } GET_QP_SAD(x+1, y-1); if (Sad<Sad0) { Sad0 = Sad; dx= 1; dy=-1; } GET_QP_SAD(x+1, y+1); if (Sad<Sad0) { Sad0 = Sad; dx= 1; dy= 1; } MV[0] = x+dx; MV[1] = y+dy; } Best_Sad = Sad0; return Best_Sad;}#undef GET_HP_SAD#undef GET_QP_SAD#undef REFINE_METHOD#undef FUNC_NAME#undef BPS#endif /* SKL_AUTO_INCLUDE */#ifndef SKL_AUTO_INCLUDE#define TEST_HP(Ref,DX,DY) \ Sad = Metric(Src, (Ref), BpS) + MV_Bits_Cost_Raw(x+(DX), y+(DY)); \ if (Sad<Sad0) { Sad0 = Sad; dx = (DX); dy = (DY); }SKL_UINT32 ME_MAP::Sad_Cost_QP(const SKL_BYTE * const *HPels, int Offset, const int x, const int y) const{ SKL_UINT32 Cost; const int q = (x&3) | (4*(y&3)); Offset += (x>>2) + (y>>2)*BpS; const SKL_BYTE * const Ref = HPels[0] + Offset; const SKL_BYTE * const Ref_H = HPels[1] + Offset; const SKL_BYTE * const Ref_V = HPels[2] + Offset; const SKL_BYTE * const Ref_HV = HPels[3] + Offset; switch(q) { // Warning ! SAD is the only supported metric (TODO ?) default: case 0: Cost = Metric( Src, Ref, BpS); break; case 1: Cost = Metric_Avrg(Src, Ref,Ref_H, BpS); break; case 2: Cost = Metric( Src, Ref_H, BpS); break; case 3: Cost = Metric_Avrg(Src, Ref+1,Ref_H, BpS); break; case 4: Cost = Metric_Avrg(Src, Ref,Ref_V, BpS); break; case 5: Cost = Metric_Avrg(Src, Ref_H, Ref_V, BpS); break; case 6: Cost = Metric_Avrg(Src, Ref_HV, Ref_H, BpS); break; case 7: Cost = Metric_Avrg(Src, Ref_V+1, Ref_H, BpS); break; case 8: Cost = Metric( Src, Ref_V, BpS); break; case 9: Cost = Metric_Avrg(Src, Ref_V, Ref_HV, BpS); break; case 10: Cost = Metric( Src, Ref_HV, BpS); break; case 11: Cost = Metric_Avrg(Src, Ref_V+1, Ref_HV, BpS); break; case 12: Cost = Metric_Avrg(Src, Ref+BpS,Ref_V, BpS); break; case 13: Cost = Metric_Avrg(Src, Ref_V, Ref_H+BpS, BpS); break; case 14: Cost = Metric_Avrg(Src, Ref_H+BpS, Ref_HV, BpS); break; case 15: Cost = Metric_Avrg(Src, Ref_V+1, Ref_H+BpS, BpS); break; } Cost += MV_Bits_Cost_Raw(x,y); return Cost;}#define TEST_QP(X,Y) \ Sad = Sad_Cost_QP(HPels, Offset0, x+(X), y+(Y)); \ if (Sad<Sad0) { Sad0 = Sad; dx = (X); dy = (Y); }SKL_UINT32 ME_MAP::Refine_MV_HPels(SKL_MV MV, const int Prec, const int Rounding, const SKL_BYTE * const *HPels){ if (Prec==2) { MV[0] = Best_MV[0] << 2; MV[1] = Best_MV[1] << 2; } else { MV[0] = Best_MV[0] << 1; MV[1] = Best_MV[1] << 1; } if (Prec==0) return Best_Sad; int x = MV[0]; int y = MV[1]; const int Offset0 = Ref - Ref0; const int Offset = Offset0 + Best_MV[0] + Best_MV[1]*BpS; // input MV is FULL pel SKL_UINT32 Sad0 = Best_Sad; SKL_UINT32 Sad = Sad0; int dx, dy; dx = 0; dy = 0; TEST_HP(HPels[1]+Offset-1 ,-Prec, 0); TEST_HP(HPels[1]+Offset , Prec, 0); TEST_HP(HPels[2]+Offset-BpS , 0, -Prec); TEST_HP(HPels[2]+Offset , 0, Prec); TEST_HP(HPels[3]+Offset-1-BpS,-Prec, -Prec); TEST_HP(HPels[3]+Offset , Prec, Prec); TEST_HP(HPels[3]+Offset-BpS , Prec, -Prec); TEST_HP(HPels[3]+Offset-1 ,-Prec, Prec); if (Prec==1) goto End;#if 1 x += dx; y += dy; dx = 0; dy = 0; TEST_QP(-1,-1); TEST_QP(+0,-1); TEST_QP(+1,-1); TEST_QP(-1,+0); TEST_QP(+1,+0); TEST_QP(-1,+1); TEST_QP(+0,+1); TEST_QP(+1,+1);#else // Not very faster... and misses a lot of better matches if (dy==0) { const int midx = dx>>1; TEST_QP( +0,+1); TEST_QP( +0,-1); if (dx>=0) { TEST_QP(+1,0); } if (dx<=0) { TEST_QP(-1,0); } TEST_QP(midx,+1); TEST_QP(midx,-1); } else if (dx==0) { const int midy = dy>>1; TEST_QP(+1, 0); TEST_QP(-1, 0); if (dy>=0) { TEST_QP( 0, 1); } if (dy<=0) { TEST_QP( 0,-1); } TEST_QP(+1,midy); TEST_QP(-1,midy); } else { const int midx = dx>>1; const int midy = dy>>1; TEST_QP(midx, 0); TEST_QP( 0,midy); TEST_QP(midx,midy); }#endifEnd: MV[0] = x + dx; MV[1] = y + dy; Best_Sad = Sad0; return Sad0;}#undef TEST_HP#undef TEST_QP//////////////////////////////////////////////////////////// Refinement pass////////////////////////////////////////////////////////// /* TODO: Put elsewhere */ // Map from Availability-bits to Prediction Type: // Pred Type is the following, used in descending probability: // . Median with 3 vectors // . Median with 2 vectors (!Top/!Top_Right/!Left) + zero-vector // . Copy vector (Left, Top, Top_Right) // . Zero vector // ABits is : Left_Ok|Top_Ok|Right_Ok|Bottom_Okstatic const SKL_BYTE Pred_Type_ABits[16][4] = { // index: [ABits (4b)][Blk=0..3] {7, 1, 2, 0} , {1, 1, 0, 0} , {5, 4, 2, 0} , {4, 4, 0, 0} , {7, 1, 2, 0} , {1, 1, 0, 0} , {2, 0, 2, 0} , {0, 0, 0, 0} , {7, 1, 2, 0} , {1, 1, 0, 0} , {5, 4, 2, 0} , {4, 4, 0, 0} , {7, 1, 2, 0} , {1, 1, 0, 0} , {2, 0, 2, 0} , {0, 0, 0, 0}};static const int Top_Neighbors[4] = { 2, 1, 1, -1 };static SKL_INT16 Median(SKL_INT16 x, SKL_INT16 y, SKL_INT16 z) { SKL_INT16 m = x; SKL_INT16 M = x; if (y < m) m = y; else M = y; if (z <= m) return m; else if (z >= M) return M; else return z;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -