21,497
社区成员




Intel® Integrated Performance Primitives Reference Manual, Volume 2: Image and Video Processing
4 Image Data Exchange and 4 Initialization Function
Convert
Converts image pixel values from one data type to another.
Syntax
Case 1: Conversion to increase bit depth and change signed to unsigned type
……
Case 2: Conversion to reduce bit depth and change unsigned to signed type:
integer to integer type
IppStatus ippiConvert_8u1u_C1R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep,
int dstBitOffset, IppiSize roiSize, Ipp8u threshold);
IppStatus ippiConvert_<mod>(const Ipp<scrDatatype>* pSrc, int srcStep, Ipp<dstDatatype>*
pDst, int dstStep, IppiSize roiSize);
Supported values for mod:
16u8u_C1R 16s8u_C1R 32s8u_C1R 32s8s_C1R
16u8u_C3R 16s8u_C3R 32s8u_C3R 32s8s_C3R
16u8u_C4R 16s8u_C4R 32s8u_C4R 32s8s_C4R
16u8u_AC4R 16s8u_AC4R 32s8u_AC4R 32s8s_AC4R
……
Description
The function ippiConvert is declared in the ippi.h file. It operates with ROI (see Regions of Interest in Intel IPP).
This function converts pixel values in the source image ROI pSrc to a different data type and writes them to the destination image ROI pDst.
The result of integer operations is always saturated to the destination data type range. It means that if the value
of the source pixel is out of the data range of the destination image, the value of the corresponding destination pixel is set to the value of the lower or upper bound (minimum or maximum) of the destination data range:
x = pSrc[i,j]
if (x > MAX_VAL) x = MAX_VAL
if (x < MIN_VAL) x = MIN_VAL
pDst[i,j] = (CASTING)x
//matlab 代码
tic; //计时开始
datSz = 16384;
// 数据规模 ,和LZ 的#define DATASIZE 16384
tDat = round(-128 + (383--128).*rand(datSz,4));
//生成数据, 随机数据,范围 -128 ~ 383,参照LZ的
tDat(tDat<0)=0; //小于0的归0
tDat(tDat>255)=255; //大于255的归255
tDat= fix(tDat);
//小数的变为整数。 因为matlab是 double类型的数据。 如果需转为int16等,也可转
toc //计时结束
Elapsed time is 0.007347 seconds. //耗时 0.007 秒
最后检查看看数据, 抽取若干个,
tDat(1:3000:end,:)
ans =
20 255 93 0
17 0 255 0
183 0 236 158
171 255 0 255
0 171 102 0
140 60 161 255
###########intel
== noif:VC2010(64) on 64bit ==<Press any key to continue>
f0_if[1]: 921
f0_if[2]: 903
f0_if[3]: 920
f1_min[1]: 277
f1_min[2]: 280
f1_min[3]: 290
f2_neg[1]: 457
f2_neg[2]: 447
f2_neg[3]: 446
f3_sar[1]: 367
f3_sar[2]: 388
f3_sar[3]: 378
f5_sse[1]: 25.5
f5_sse[2]: 25.2
f5_sse[3]: 25.4
<Press any key to exit>
##########VC 2010
== noif:VC2010(64) on 64bit ==<Press any key to continue>
f0_if[1]: 1465
f0_if[2]: 1439
f0_if[3]: 1453
f1_min[1]: 1583
f1_min[2]: 1554
f1_min[3]: 1580
f2_neg[1]: 379
f2_neg[2]: 378
f2_neg[3]: 380
f3_sar[1]: 244
f3_sar[2]: 252
f3_sar[3]: 250
f5_sse[1]: 26.0
f5_sse[2]: 25.8
f5_sse[3]: 25.3
<Press any key to exit>
----------------------
visual studio 2010
== noif:VC2010(32) on 64bit ==<Press any key to continue>
f0_if[1]: 1526
f0_if[2]: 1531
f0_if[3]: 1503
f1_min[1]: 2190
f1_min[2]: 2221
f1_min[3]: 2205
f2_neg[1]: 421
f2_neg[2]: 423
f2_neg[3]: 414
f3_sar[1]: 321
f3_sar[2]: 327
f3_sar[3]: 329
<Press any key to exit>
-----------------------
intel parallel studio 2011 xe
== noif:VC2010(32) on 64bit ==<Press any key to continue>
f0_if[1]: 900
f0_if[2]: 876
f0_if[3]: 874
f1_min[1]: 271
f1_min[2]: 270
f1_min[3]: 267
f2_neg[1]: 462
f2_neg[2]: 453
f2_neg[3]: 458
f3_sar[1]: 379
f3_sar[2]: 373
f3_sar[3]: 380
<Press any key to exit>
VC 2010
PUBLIC ?f1_min@@YAXPAEPBFH@Z ; f1_min
; Function compile flags: /Ogtp
; COMDAT ?f1_min@@YAXPAEPBFH@Z
_TEXT SEGMENT
_pbufD$ = 8 ; size = 4
_pbufS$ = 12 ; size = 4
_cnt$ = 16 ; size = 4
?f1_min@@YAXPAEPBFH@Z PROC ; f1_min, COMDAT
; 60 : {
push ebp
mov ebp, esp
; 62 : BYTE* pD = pbufD;
; 63 : int i;
; 64 : for(i=0; i<cnt; ++i)
mov eax, DWORD PTR _cnt$[ebp]
test eax, eax
jle $LN1@f1_min
; 61 : const signed short* pS = pbufS;
mov ecx, DWORD PTR _pbufD$[ebp]
push esi
mov esi, DWORD PTR _pbufS$[ebp]
push edi
add ecx, 2
add esi, 4
mov edi, eax
npad 2
$LL3@f1_min:
; 65 : {
; 66 : // 分别对4个通道做饱和处理
; 67 : pD[0] = min(max(0, pS[0]), 255);
movzx eax, WORD PTR [esi-4]
xor edx, edx
cmp dx, ax
jg SHORT $LN32@f1_min
cmp ax, 255 ; 000000ffH
jge SHORT $LN10@f1_min
$LN32@f1_min:
xor edx, edx
cmp dx, ax
jle SHORT $LN8@f1_min
xor eax, eax
jmp SHORT $LN11@f1_min
$LN8@f1_min:
cwde
jmp SHORT $LN11@f1_min
$LN10@f1_min:
mov eax, 255 ; 000000ffH
$LN11@f1_min:
mov BYTE PTR [ecx-2], al
; 68 : pD[1] = min(max(0, pS[1]), 255);
movzx eax, WORD PTR [esi-2]
xor edx, edx
cmp dx, ax
jg SHORT $LN33@f1_min
cmp ax, 255 ; 000000ffH
jge SHORT $LN16@f1_min
$LN33@f1_min:
xor edx, edx
cmp dx, ax
jle SHORT $LN14@f1_min
xor eax, eax
jmp SHORT $LN17@f1_min
$LN14@f1_min:
cwde
jmp SHORT $LN17@f1_min
$LN16@f1_min:
mov eax, 255 ; 000000ffH
$LN17@f1_min:
mov BYTE PTR [ecx-1], al
; 69 : pD[2] = min(max(0, pS[2]), 255);
movzx eax, WORD PTR [esi]
xor edx, edx
cmp dx, ax
jg SHORT $LN34@f1_min
cmp ax, 255 ; 000000ffH
jge SHORT $LN22@f1_min
$LN34@f1_min:
xor edx, edx
cmp dx, ax
jle SHORT $LN20@f1_min
xor eax, eax
jmp SHORT $LN23@f1_min
$LN20@f1_min:
cwde
jmp SHORT $LN23@f1_min
$LN22@f1_min:
mov eax, 255 ; 000000ffH
$LN23@f1_min:
mov BYTE PTR [ecx], al
; 70 : pD[3] = min(max(0, pS[3]), 255);
movzx eax, WORD PTR [esi+2]
xor edx, edx
cmp dx, ax
jg SHORT $LN35@f1_min
cmp ax, 255 ; 000000ffH
jge SHORT $LN28@f1_min
$LN35@f1_min:
xor edx, edx
cmp dx, ax
jle SHORT $LN26@f1_min
xor eax, eax
jmp SHORT $LN29@f1_min
$LN26@f1_min:
cwde
jmp SHORT $LN29@f1_min
$LN28@f1_min:
mov eax, 255 ; 000000ffH
$LN29@f1_min:
mov BYTE PTR [ecx+1], al
; 71 : // next
; 72 : pS += 4;
add esi, 8
; 73 : pD += 4;
add ecx, 4
dec edi
jne $LL3@f1_min
pop edi
pop esi
$LN1@f1_min:
; 74 : }
; 75 : }
pop ebp
ret 0
?f1_min@@YAXPAEPBFH@Z ENDP ; f1_min
_TEXT ENDS
_TEXT SEGMENT PARA PUBLIC FLAT 'CODE'
; COMDAT ?f1_min@@YAXPAEPBFH@Z
TXTST2:
; -- Begin ?f1_min@@YAXPAEPBFH@Z
; mark_begin;
ALIGN 16
PUBLIC ?f1_min@@YAXPAEPBFH@Z
?f1_min@@YAXPAEPBFH@Z PROC NEAR
; parameter 1(pbufD): 20 + esp
; parameter 2(pbufS): 24 + esp
; parameter 3(cnt): 28 + esp
.B3.1: ; Preds .B3.0
;;; {
$LN501:
sub esp, 16 ;60.1
$LN502:
mov edx, DWORD PTR [28+esp] ;59.6
$LN503:
;;; const signed short* pS = pbufS;
;;; BYTE* pD = pbufD;
;;; int i;
;;; for(i=0; i<cnt; ++i)
test edx, edx ;64.2
$LN504:
jle .B3.5 ; Prob 10% ;64.2
$LN505:
; LOE edx ebx ebp esi edi
.B3.2: ; Preds .B3.1
xor ecx, ecx ;
mov DWORD PTR [12+esp], esi ;
xor eax, eax ;
mov DWORD PTR [8+esp], edi ;
mov DWORD PTR [4+esp], ebx ;
mov DWORD PTR [esp], ebp ;
mov ebp, 255 ;
mov esi, DWORD PTR [24+esp] ;
mov edi, DWORD PTR [20+esp] ;
ALIGN 16
$LN506:
; LOE eax edx ecx ebp esi edi
.B3.3: ; Preds .B3.3 .B3.2
$LN507:
;;; {
;;; // 分别对4个通道做饱和处理
;;; pD[0] = min(max(0, pS[0]), 255);
movsx ebx, WORD PTR [esi+ecx*8] ;67.3
$LN508:
test ebx, ebx ;67.3
$LN509:
cmovl ebx, eax ;67.3
$LN510:
cmp ebx, 255 ;67.3
$LN511:
cmovge ebx, ebp ;67.3
$LN512:
mov BYTE PTR [edi+ecx*4], bl ;67.3
$LN513:
movsx ebx, WORD PTR [2+esi+ecx*8] ;67.3
$LN514:
test ebx, ebx ;67.3
$LN515:
cmovl ebx, eax ;67.3
$LN516:
cmp ebx, 255 ;67.3
$LN517:
cmovge ebx, ebp ;67.3
$LN518:
mov BYTE PTR [1+edi+ecx*4], bl ;67.3
$LN519:
movsx ebx, WORD PTR [4+esi+ecx*8] ;67.3
$LN520:
test ebx, ebx ;67.3
$LN521:
cmovl ebx, eax ;67.3
$LN522:
cmp ebx, 255 ;67.3
$LN523:
cmovge ebx, ebp ;67.3
$LN524:
mov BYTE PTR [2+edi+ecx*4], bl ;67.3
$LN525:
movsx ebx, WORD PTR [6+esi+ecx*8] ;67.3
$LN526:
test ebx, ebx ;67.3
$LN527:
cmovl ebx, eax ;67.3
$LN528:
cmp ebx, 255 ;67.3
$LN529:
cmovge ebx, ebp ;67.3
$LN530:
mov BYTE PTR [3+edi+ecx*4], bl ;67.3
$LN531:
inc ecx ;64.2
$LN532:
cmp ecx, edx ;64.2
$LN533:
jb .B3.3 ; Prob 78% ;64.2
$LN534:
; LOE eax edx ecx ebp esi edi
.B3.4: ; Preds .B3.3
mov esi, DWORD PTR [12+esp] ;
mov edi, DWORD PTR [8+esp] ;
mov ebx, DWORD PTR [4+esp] ;
mov ebp, DWORD PTR [esp] ;
$LN535:
; LOE ebx ebp esi edi
.B3.5: ; Preds .B3.4 .B3.1
;;; pD[1] = min(max(0, pS[1]), 255);
;;; pD[2] = min(max(0, pS[2]), 255);
;;; pD[3] = min(max(0, pS[3]), 255);
;;; // next
;;; pS += 4;
;;; pD += 4;
;;; }
;;; }
$LN536:
add esp, 16 ;75.1
$LN537:
ret ;75.1
ALIGN 16
$LN538:
; LOE
$LN539:
; mark_end;
?f1_min@@YAXPAEPBFH@Z ENDP
$LN?f1_min@@YAXPAEPBFH@Z$540:
$LN?f1_min@@YAXPAEPBFH@Z$541:
;?f1_min@@YAXPAEPBFH@Z ENDS
_TEXT ENDS
_DATA SEGMENT DWORD PUBLIC FLAT 'DATA'
_DATA ENDS
; -- End ?f1_min@@YAXPAEPBFH@Z