home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / Riza / source / a_resync.asm next >
Encoding:
Assembly Source File  |  2009-09-14  |  2.5 KB  |  106 lines

  1. ;    VirtualDub - Video processing and capture application
  2. ;    A/V interface library    
  3. ;    Copyright (C) 1998-2008 Avery Lee
  4. ;
  5. ;    This program is free software; you can redistribute it and/or modify
  6. ;    it under the terms of the GNU General Public License as published by
  7. ;    the Free Software Foundation; either version 2 of the License, or
  8. ;    (at your option) any later version.
  9. ;
  10. ;    This program is distributed in the hope that it will be useful,
  11. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;    GNU General Public License for more details.
  14. ;
  15. ;    You should have received a copy of the GNU General Public License
  16. ;    along with this program; if not, write to the Free Software
  17. ;    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.         extern        _gVDCaptureAudioResamplingKernel : near
  20.  
  21.     segment    .rdata, align=16
  22.  
  23. rounder    dd            00002000h
  24.  
  25.     segment    .text
  26.  
  27.     global    _vdasm_capture_resample16_MMX
  28. _vdasm_capture_resample16_MMX:
  29.  
  30.         push        ebp
  31.         push        edi
  32.         push        esi
  33.         push        ebx
  34.  
  35.         mov            edx, [esp+4+16]        ;edx = destination
  36.         mov            ebp, [esp+8+16]        ;ebp = stride
  37.         mov            ecx, [esp+12+16]    ;ecx = source
  38.         mov            eax, [esp+16+16]    ;eax = counter
  39.         shr            ecx, 1
  40.         add            ebp, ebp            ;convert sample stride to pointer stride
  41.         mov            esi, [esp+20+16]    ;esi = fractional accumulator
  42.         add            ecx, [esp+24+16]    ;add integer accumulator
  43.         mov            ebx, [esp+32+16]    ;ebx = integer increment
  44.  
  45.         push        0
  46.         push        dword [fs:0]
  47.         mov            dword [fs:0], esp
  48.  
  49.         mov            esp, [esp+28+24]    ;esp = fractional increment
  50.  
  51.         movd        mm6, [rounder]
  52.  
  53.         ;eax        loop counter
  54.         ;ebx        integer increment
  55.         ;ecx        source
  56.         ;edx        destination
  57.         ;esi        fractional accumulator
  58.         ;edi        current filter
  59.         ;esp        fractional increment
  60.         ;ebp        destination stride
  61.  
  62.         mov            edi, esi
  63.         shr            edi, 23
  64.         and            edi, 1f0h
  65.         add            edi, _gVDCaptureAudioResamplingKernel
  66.  
  67. xloop:
  68.         movq        mm0, [ecx+ecx]
  69.         pmaddwd        mm0, [edi]
  70.         movq        mm1, [ecx+ecx+8]
  71.         pmaddwd        mm1, [edi+8]
  72.         paddd        mm0, mm1
  73.         movq        mm1, mm0
  74.         psrlq        mm0, 32
  75.         paddd        mm0, mm1
  76.         paddd        mm0, mm6
  77.         psrad        mm0, 14
  78.         packssdw    mm0, mm0
  79.         movd        edi, mm0
  80.         mov            [edx], di
  81.  
  82.         add            esi, esp
  83.         adc            ecx, ebx
  84.         mov            edi, esi
  85.         shr            edi, 23
  86.         add            edx, ebp
  87.         and            edi, 1f0h
  88.         add            edi, _gVDCaptureAudioResamplingKernel
  89.  
  90.         sub            eax, 1
  91.         jne            xloop
  92.  
  93.         mov            esp, dword [fs:0]
  94.         pop            dword [fs:0]
  95.         pop            eax
  96.  
  97.         emms
  98.         pop            ebx
  99.         pop            esi
  100.         pop            edi
  101.         pop            ebp
  102.         ret
  103.  
  104.  
  105.         end
  106.