📄 umc_h264_sad.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 - 2005 Intel Corporation. All Rights Reserved.//#include <string.h>#include "umc_h264_video_encoder.h"#include "umc_h264_tables.h"#include "ippvc.h"using namespace UMC_H264_ENCODER;namespace UMC{//////////////////////////////////////////////////////////////////////////////////// C_SAD4x4Block4//// Returns the sum of the absolute differences of two 4x4 blocks.//// Blocks can have different pitches.//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD4x4Block4( const Ipp8u *pSource0, Ipp32u uPitch0, const Ipp8u *pSource1, Ipp32u uPitch1){ Ipp32s SAD; ippiSAD4x4_8u32s(pSource0,uPitch0,pSource1,uPitch1,&SAD,0); return SAD;}//////////////////////////////////////////////////////////////////////////////////// C_SAD4x4Block//// Returns the sum of the absolute differences of two 4x4 blocks.//// Both blocks have the same pitch.//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD4x4Block( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp32u uPitch){ Ipp32s SAD; //IppiSAD4x4_8u32s(pSource0,uPitch,pSource1,uPitch,&SAD,0); ippiSAD4x4_8u32s(pSource0,uPitch,pSource1,uPitch,&SAD,0); return SAD;}//////////////////////////////////////////////////////////////////////////////////// C_SAD4x4Block_P16//// Returns the sum of the absolute differences of two 4x4 blocks.//// Source0 has specified pitch, Source1 has a pitch of 16..//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD4x4Block_P16( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp32u uPitch0){ Ipp32s SAD; //IppiSAD4x4_8u32s(pSource0,uPitch0,pSource1,16,&SAD,0); ippiSAD4x4_8u32s(pSource0,uPitch0,pSource1,16,&SAD,0); return SAD;}//////////////////////////////////////////////////////////////////////////////////// C_SAD8x8Block//// Returns the sum of the absolute differences of two 8x8 blocks.//// Both blocks have the same pitch.//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD8x8Block( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp32u uPitch){ Ipp32s SAD; ippiSAD8x8_8u32s_C1R(pSource0,uPitch,pSource1,uPitch,&SAD,0); //IppiSAD8x8_8u32s(pSource0,uPitch,pSource1,uPitch,&SAD,0); return SAD;}//////////////////////////////////////////////////////////////////////////////////// C_SAD8x8Block_P16//// Returns the sum of the absolute differences of two 8x8 blocks.//// Source0 has specified pitch, Source1 has a pitch of 16..//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD8x8Block_P16( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp32u uPitch0){ Ipp32s SAD; ippiSAD8x8_8u32s_C1R(pSource0,uPitch0,pSource1,16,&SAD,0); return SAD;}//////////////////////////////////////////////////////////////////////////////////// C_SAD16x16Block//// Returns the sum of the absolute differences of two 16x16 blocks.//// Both blocks have the same pitch.//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD16x16Block( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp32u uPitch){ Ipp32s SAD; ippiSAD16x16_8u32s(pSource0,uPitch,pSource1,uPitch,&SAD,0); return SAD;}//////////////////////////////////////////////////////////////////////////////////// C_SAD16x16Block_P16//// Returns the sum of the absolute differences of two 16x16 blocks.//// Source0 has specified pitch, Source1 has a pitch of 16..//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD16x16Block_P16( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp32u uPitch0){ Ipp32s SAD; ippiSAD16x16_8u32s(pSource0,uPitch0,pSource1,16,&SAD,0); return SAD;}//////////////////////////////////////////////////////////////////////////////////// C_SAD16x16Block_Sb4//// Returns the 4 partial sums of the absolute differences of two 16x16 blocks.//// Both blocks have the same pitch.//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD16x16Block_Sb4( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp16u *pResults, Ipp32u uPitch){ ippiSAD16x16Blocks8x8_8u16u(pSource0,uPitch,pSource1,uPitch,pResults,0); return 0;}static const Ipp8s BlockList4x4[25][17] = { {0, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 8 4x8 Blocks - 16 {1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {12, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {13, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 8 8x4 Blocks - 24 {2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 4 8x8 Blocks - 32 {4, 5, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 2, 3, 8, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 2 8x16 Blocks - 36 {4, 5, 6, 7, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 2 16x8 Blocks - 38 {8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1} // 1 16x16 Block - 40 };//////////////////////////////////////////////////////////////////////////////////// C_SAD16x16Block_Sb16//// Returns the 16 partial sums of the absolute differences of two 16x16 blocks.//// Both blocks have the same pitch.//////////////////////////////////////////////////////////////////////////////////Ipp32u SAD16x16Block_Sb16( const Ipp8u *pSource0, const Ipp8u *pSource1, Ipp16u *ThisSAD, Ipp32u uPitch){ Ipp32u block; Ipp32u tempBlock; int tempSAD; Ipp16u tempSADs[16]; const Ipp8s *pBlockList; ippiSAD16x16Blocks4x4_8u16u(pSource0,uPitch,pSource1,uPitch,tempSADs,0); for (block = 0; block < 16; ++block) { tempBlock = block_subblock_mapping[block]; ThisSAD[tempBlock] = tempSADs[block]; } // block // Accumulate SAD and MVs for all other block sizes for (block = 16; block < 41; ++block) { pBlockList = BlockList4x4[block-16]; tempSAD = 0; while (*pBlockList >= 0) tempSAD += ThisSAD[*pBlockList++]; ThisSAD[block] = (Ipp16u)tempSAD; } return 0;}} //namespace UMC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -