4686 lines · 157.5 KB · Assembly
RawDownload
;*!;* \copy;*     Copyright (c)  2009-2013, Cisco Systems;*     All rights reserved.;*;*     Redistribution and use in source and binary forms, with or without;*     modification, are permitted provided that the following conditions;*     are met:;*;*        * Redistributions of source code must retain the above copyright;*          notice, this list of conditions and the following disclaimer.;*;*        * Redistributions in binary form must reproduce the above copyright;*          notice, this list of conditions and the following disclaimer in;*          the documentation and/or other materials provided with the;*          distribution.;*;*     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS;*     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT;*     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS;*     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE;*     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,;*     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,;*     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;;*     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER;*     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT;*     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN;*     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE;*     POSSIBILITY OF SUCH DAMAGE.;*;*;*  upsampling.asm;*;*  Abstract;*      SIMD for pixel domain down sampling;*;*  History;*      10/22/2009  Created;*;*************************************************************************/%include "asm_inc.asm" %ifdef __NASM_VER__    %use smartalign%endif ;***********************************************************************; Macros and other preprocessor constants;***********************************************************************  ;***********************************************************************; Some constants;*********************************************************************** ;***********************************************************************; Local Data (Read Only);*********************************************************************** %ifdef X86_32_PICASMSECTION .text align=32%elseSECTION .rodata align=32%endif ;***********************************************************************; Various memory constants (trigonometric values or rounding values);*********************************************************************** ALIGN 32%ifndef X86_32_PICASMdb80h_256:    times 32 db 80hshufb_0000000088888888:    times 8 db 0    times 8 db 8shufb_000044448888CCCC:    times 4 db 0    times 4 db 4    times 4 db 8    times 4 db 12%endifshufb_mask_low:    db 00h, 80h, 02h, 80h, 04h, 80h, 06h, 80h, 08h, 80h, 0ah, 80h, 0ch, 80h, 0eh, 80hshufb_mask_high:    db 01h, 80h, 03h, 80h, 05h, 80h, 07h, 80h, 09h, 80h, 0bh, 80h, 0dh, 80h, 0fh, 80hadd_extra_half:    dd 16384,0,0,0 shufb_mask_quarter:db 00h, 04h, 08h, 0ch, 80h, 80h, 80h, 80h, 01h, 05h, 09h, 0dh, 80h, 80h, 80h, 80h shufb_mask_onethird_low_1:db 00h, 03h, 06h, 09h, 0ch, 0fh, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80hshufb_mask_onethird_low_2:db 80h, 80h, 80h, 80h, 80h, 80h, 02h, 05h, 08h, 0bh, 0eh, 80h, 80h, 80h, 80h, 80hshufb_mask_onethird_low_3:db 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 01h, 04h, 07h, 0ah, 0dh shufb_mask_onethird_high_1:db 01h, 04h, 07h, 0ah, 0dh, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80hshufb_mask_onethird_high_2:db 80h, 80h, 80h, 80h, 80h, 00h, 03h, 06h, 09h, 0ch, 0fh, 80h, 80h, 80h, 80h, 80hshufb_mask_onethird_high_3:db 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 80h, 02h, 05h, 08h, 0bh, 0eh ;***********************************************************************; Code;*********************************************************************** SECTION .text ;***********************************************************************;   void DyadicBilinearDownsamplerWidthx32_sse( unsigned char* pDst, const int iDstStride,;                   unsigned char* pSrc, const int iSrcStride,;                   const int iSrcWidth, const int iSrcHeight );;***********************************************************************WELS_EXTERN DyadicBilinearDownsamplerWidthx32_sse%ifdef X86_32    push r6    %assign push_num 1%else    %assign push_num 0%endif    LOAD_6_PARA    SIGN_EXTENSION r1, r1d    SIGN_EXTENSION r3, r3d    SIGN_EXTENSION r4, r4d    SIGN_EXTENSION r5, r5d %ifndef X86_32    push r12    mov r12, r4%endif    sar r5, $01            ; iSrcHeight >> 1 .yloops1:%ifdef X86_32    mov r4, arg5%else    mov r4, r12%endif    sar r4, $01            ; iSrcWidth >> 1    mov r6, r4        ; iDstWidth restored at ebx    sar r4, $04            ; (iSrcWidth >> 1) / 16     ; loop count = num_of_mb    neg r6             ; - (iSrcWidth >> 1)    ; each loop = source bandwidth: 32 bytes.xloops1:    ; 1st part horizonal loop: x16 bytes    ;               mem  hi<-       ->lo    ;1st Line Src:  mm0: d D c C b B a A    mm1: h H g G f F e E    ;2nd Line Src:  mm2: l L k K j J i I    mm3: p P o O n N m M    ;=> target:    ;: H G F E D C B A, P O N M L K J I    ;: h g f e d c b a, p o n m l k j i    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    movq mm0, [r2]         ; 1st pSrc line    movq mm1, [r2+8]       ; 1st pSrc line + 8    movq mm2, [r2+r3]     ; 2nd pSrc line    movq mm3, [r2+r3+8]   ; 2nd pSrc line + 8     ; to handle mm0, mm1, mm2, mm3    pshufw mm4, mm0, 0d8h   ; d D b B c C a A ; 11011000 B    pshufw mm5, mm4, 04eh   ; c C a A d D b B ; 01001110 B    punpcklbw mm4, mm5      ; d c D C b a B A    pshufw mm4, mm4, 0d8h   ; d c b a D C B A ; 11011000 B: mm4     pshufw mm5, mm1, 0d8h   ; h H f F g G e E ; 11011000 B    pshufw mm6, mm5, 04eh   ; g G e E h H f F ; 01001110 B    punpcklbw mm5, mm6      ; h g H G f e F E    pshufw mm5, mm5, 0d8h   ; h g f e H G F E ; 11011000 B: mm5     pshufw mm6, mm2, 0d8h   ; l L j J k K i I ; 11011000 B    pshufw mm7, mm6, 04eh   ; k K i I l L j J ; 01001110 B    punpcklbw mm6, mm7      ; l k L K j i J I    pshufw mm6, mm6, 0d8h   ; l k j i L K J I ; 11011000 B: mm6     pshufw mm7, mm3, 0d8h   ; p P n N o O m M ; 11011000 B    pshufw mm0, mm7, 04eh   ; o O m M p P n N ; 01001110 B    punpcklbw mm7, mm0      ; p o P O n m N M    pshufw mm7, mm7, 0d8h   ; p o n m P O N M ; 11011000 B: mm7     ; to handle mm4, mm5, mm6, mm7    movq mm0, mm4       ;    punpckldq mm0, mm5  ; H G F E D C B A    punpckhdq mm4, mm5  ; h g f e d c b a     movq mm1, mm6    punpckldq mm1, mm7  ; P O N M L K J I    punpckhdq mm6, mm7  ; p o n m l k j i     ; avg within MB horizon width (16 x 2 lines)    pavgb mm0, mm4      ; (A+a+1)>>1, .., (H+h+1)>>1, temp_row1    pavgb mm1, mm6      ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2    pavgb mm0, mm1      ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once     ; 2nd part horizonal loop: x16 bytes    ;               mem  hi<-       ->lo    ;1st Line Src:  mm0: d D c C b B a A    mm1: h H g G f F e E    ;2nd Line Src:  mm2: l L k K j J i I    mm3: p P o O n N m M    ;=> target:    ;: H G F E D C B A, P O N M L K J I    ;: h g f e d c b a, p o n m l k j i    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    movq mm1, [r2+16]      ; 1st pSrc line + 16    movq mm2, [r2+24]      ; 1st pSrc line + 24    movq mm3, [r2+r3+16]  ; 2nd pSrc line + 16    movq mm4, [r2+r3+24]  ; 2nd pSrc line + 24     ; to handle mm1, mm2, mm3, mm4    pshufw mm5, mm1, 0d8h   ; d D b B c C a A ; 11011000 B    pshufw mm6, mm5, 04eh   ; c C a A d D b B ; 01001110 B    punpcklbw mm5, mm6      ; d c D C b a B A    pshufw mm5, mm5, 0d8h   ; d c b a D C B A ; 11011000 B: mm5     pshufw mm6, mm2, 0d8h   ; h H f F g G e E ; 11011000 B    pshufw mm7, mm6, 04eh   ; g G e E h H f F ; 01001110 B    punpcklbw mm6, mm7      ; h g H G f e F E    pshufw mm6, mm6, 0d8h   ; h g f e H G F E ; 11011000 B: mm6     pshufw mm7, mm3, 0d8h   ; l L j J k K i I ; 11011000 B    pshufw mm1, mm7, 04eh   ; k K i I l L j J ; 01001110 B    punpcklbw mm7, mm1      ; l k L K j i J I    pshufw mm7, mm7, 0d8h   ; l k j i L K J I ; 11011000 B: mm7     pshufw mm1, mm4, 0d8h   ; p P n N o O m M ; 11011000 B    pshufw mm2, mm1, 04eh   ; o O m M p P n N ; 01001110 B    punpcklbw mm1, mm2      ; p o P O n m N M    pshufw mm1, mm1, 0d8h   ; p o n m P O N M ; 11011000 B: mm1     ; to handle mm5, mm6, mm7, mm1    movq mm2, mm5    punpckldq mm2, mm6  ; H G F E D C B A    punpckhdq mm5, mm6  ; h g f e d c b a     movq mm3, mm7    punpckldq mm3, mm1  ; P O N M L K J I    punpckhdq mm7, mm1  ; p o n m l k j i     ; avg within MB horizon width (16 x 2 lines)    pavgb mm2, mm5      ; (A+a+1)>>1, .., (H+h+1)>>1, temp_row1    pavgb mm3, mm7      ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2    pavgb mm2, mm3      ; (temp_row1+temp_row2+1)>>1, done in another 2nd horizonal part     movq [r0  ], mm0    movq [r0+8], mm2     ; next SMB    lea r2, [r2+32]    lea r0, [r0+16]     dec r4    jg near .xloops1     ; next line    lea r2, [r2+2*r3]    ; next end of lines    lea r2, [r2+2*r6]    ; reset to base 0 [- 2 * iDstWidth]    lea r0, [r0+r1]    lea r0, [r0+r6]      ; reset to base 0 [- iDstWidth]     dec r5    jg near .yloops1     WELSEMMS%ifndef X86_32    pop r12%endif    LOAD_6_PARA_POP%ifdef X86_32    pop r6%endif    ret ;***********************************************************************;   void DyadicBilinearDownsamplerWidthx16_sse( unsigned char* pDst, const int iDstStride,;                     unsigned char* pSrc, const int iSrcStride,;                     const int iSrcWidth, const int iSrcHeight );;***********************************************************************WELS_EXTERN DyadicBilinearDownsamplerWidthx16_sse%ifdef X86_32    push r6    %assign push_num 1%else    %assign push_num 0%endif    LOAD_6_PARA    SIGN_EXTENSION r1, r1d    SIGN_EXTENSION r3, r3d    SIGN_EXTENSION r4, r4d    SIGN_EXTENSION r5, r5d %ifndef X86_32    push r12    mov r12, r4%endif    sar r5, $01            ; iSrcHeight >> 1 .yloops2:%ifdef X86_32    mov r4, arg5%else    mov r4, r12%endif    sar r4, $01            ; iSrcWidth >> 1    mov r6, r4        ; iDstWidth restored at ebx    sar r4, $03            ; (iSrcWidth >> 1) / 8     ; loop count = num_of_mb    neg r6             ; - (iSrcWidth >> 1)    ; each loop = source bandwidth: 16 bytes.xloops2:    ; 1st part horizonal loop: x16 bytes    ;               mem  hi<-       ->lo    ;1st Line Src:  mm0: d D c C b B a A    mm1: h H g G f F e E    ;2nd Line Src:  mm2: l L k K j J i I    mm3: p P o O n N m M    ;=> target:    ;: H G F E D C B A, P O N M L K J I    ;: h g f e d c b a, p o n m l k j i    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    movq mm0, [r2]         ; 1st pSrc line    movq mm1, [r2+8]       ; 1st pSrc line + 8    movq mm2, [r2+r3]     ; 2nd pSrc line    movq mm3, [r2+r3+8]   ; 2nd pSrc line + 8     ; to handle mm0, mm1, mm2, mm3    pshufw mm4, mm0, 0d8h   ; d D b B c C a A ; 11011000 B    pshufw mm5, mm4, 04eh   ; c C a A d D b B ; 01001110 B    punpcklbw mm4, mm5      ; d c D C b a B A    pshufw mm4, mm4, 0d8h   ; d c b a D C B A ; 11011000 B: mm4     pshufw mm5, mm1, 0d8h   ; h H f F g G e E ; 11011000 B    pshufw mm6, mm5, 04eh   ; g G e E h H f F ; 01001110 B    punpcklbw mm5, mm6      ; h g H G f e F E    pshufw mm5, mm5, 0d8h   ; h g f e H G F E ; 11011000 B: mm5     pshufw mm6, mm2, 0d8h   ; l L j J k K i I ; 11011000 B    pshufw mm7, mm6, 04eh   ; k K i I l L j J ; 01001110 B    punpcklbw mm6, mm7      ; l k L K j i J I    pshufw mm6, mm6, 0d8h   ; l k j i L K J I ; 11011000 B: mm6     pshufw mm7, mm3, 0d8h   ; p P n N o O m M ; 11011000 B    pshufw mm0, mm7, 04eh   ; o O m M p P n N ; 01001110 B    punpcklbw mm7, mm0      ; p o P O n m N M    pshufw mm7, mm7, 0d8h   ; p o n m P O N M ; 11011000 B: mm7     ; to handle mm4, mm5, mm6, mm7    movq mm0, mm4       ;    punpckldq mm0, mm5  ; H G F E D C B A    punpckhdq mm4, mm5  ; h g f e d c b a     movq mm1, mm6    punpckldq mm1, mm7  ; P O N M L K J I    punpckhdq mm6, mm7  ; p o n m l k j i     ; avg within MB horizon width (16 x 2 lines)    pavgb mm0, mm4      ; (A+a+1)>>1, .., (H+h+1)>>1, temp_row1    pavgb mm1, mm6      ; (I+i+1)>>1, .., (P+p+1)>>1, temp_row2    pavgb mm0, mm1      ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once     movq [r0  ], mm0     ; next SMB    lea r2, [r2+16]    lea r0, [r0+8]     dec r4    jg near .xloops2     ; next line    lea r2, [r2+2*r3]    ; next end of lines    lea r2, [r2+2*r6]    ; reset to base 0 [- 2 * iDstWidth]    lea r0, [r0+r1]    lea r0, [r0+r6]      ; reset to base 0 [- iDstWidth]     dec r5    jg near .yloops2     WELSEMMS%ifndef X86_32    pop r12%endif    LOAD_6_PARA_POP%ifdef X86_32    pop r6%endif    ret ;***********************************************************************;   void DyadicBilinearDownsamplerWidthx8_sse( unsigned char* pDst, const int iDstStride,;                     unsigned char* pSrc, const int iSrcStride,;                     const int iSrcWidth, const int iSrcHeight );;***********************************************************************WELS_EXTERN DyadicBilinearDownsamplerWidthx8_sse%ifdef X86_32    push r6    %assign push_num 1%else    %assign push_num 0%endif    LOAD_6_PARA    SIGN_EXTENSION r1, r1d    SIGN_EXTENSION r3, r3d    SIGN_EXTENSION r4, r4d    SIGN_EXTENSION r5, r5d %ifndef X86_32    push r12    mov r12, r4%endif    sar r5, $01            ; iSrcHeight >> 1 .yloops3:%ifdef X86_32    mov r4, arg5%else    mov r4, r12%endif    sar r4, $01            ; iSrcWidth >> 1    mov r6, r4        ; iDstWidth restored at ebx    sar r4, $02            ; (iSrcWidth >> 1) / 4     ; loop count = num_of_mb    neg r6             ; - (iSrcWidth >> 1)    ; each loop = source bandwidth: 8 bytes.xloops3:    ; 1st part horizonal loop: x8 bytes    ;               mem  hi<-       ->lo    ;1st Line Src:  mm0: d D c C b B a A    ;2nd Line Src:  mm1: h H g G f F e E    ;=> target:    ;: H G F E D C B A    ;: h g f e d c b a    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    movq mm0, [r2]         ; 1st pSrc line    movq mm1, [r2+r3]     ; 2nd pSrc line     ; to handle mm0, mm1, mm2, mm3    pshufw mm2, mm0, 0d8h   ; d D b B c C a A ; 11011000 B    pshufw mm3, mm2, 04eh   ; c C a A d D b B ; 01001110 B    punpcklbw mm2, mm3      ; d c D C b a B A    pshufw mm2, mm2, 0d8h   ; d c b a D C B A ; 11011000 B: mm4     pshufw mm4, mm1, 0d8h   ; h H f F g G e E ; 11011000 B    pshufw mm5, mm4, 04eh   ; g G e E h H f F ; 01001110 B    punpcklbw mm4, mm5      ; h g H G f e F E    pshufw mm4, mm4, 0d8h   ; h g f e H G F E ; 11011000 B: mm5     ; to handle mm2, mm4    movq mm0, mm2       ;    punpckldq mm0, mm4  ; H G F E D C B A    punpckhdq mm2, mm4  ; h g f e d c b a     ; avg within MB horizon width (16 x 2 lines)    pavgb mm0, mm2      ; (H+h+1)>>1, .., (A+a+1)>>1, temp_row1, 2    pshufw mm1, mm0, 04eh   ; 01001110 B    pavgb mm0, mm1      ; (temp_row1+temp_row2+1)>>1, pending here and wait another horizonal part done then write memory once     movd [r0], mm0     ; next unit    lea r2, [r2+8]    lea r0, [r0+4]     dec r4    jg near .xloops3     ; next line    lea r2, [r2+2*r3]    ; next end of lines    lea r2, [r2+2*r6]    ; reset to base 0 [- 2 * iDstWidth]    lea r0, [r0+r1]    lea r0, [r0+r6]      ; reset to base 0 [- iDstWidth]     dec r5    jg near .yloops3     WELSEMMS%ifndef X86_32    pop r12%endif    LOAD_6_PARA_POP%ifdef X86_32    pop r6%endif    ret   ;***********************************************************************;   void DyadicBilinearDownsamplerWidthx32_ssse3(   unsigned char* pDst, const int iDstStride,;                   unsigned char* pSrc, const int iSrcStride,;                   const int iSrcWidth, const int iSrcHeight );;***********************************************************************WELS_EXTERN DyadicBilinearDownsamplerWidthx32_ssse3%ifdef X86_32    push r6    %assign push_num 1%else    %assign push_num 0%endif    LOAD_6_PARA    PUSH_XMM 4    SIGN_EXTENSION r1, r1d    SIGN_EXTENSION r3, r3d    SIGN_EXTENSION r4, r4d

Lines 1–500 of 4686.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t