You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9KB

  1. ;******************************************************************************
  2. ;* x86 optimized dithering format conversion
  3. ;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
  4. ;*
  5. ;* This file is part of Libav.
  6. ;*
  7. ;* Libav is free software; you can redistribute it and/or
  8. ;* modify it under the terms of the GNU Lesser General Public
  9. ;* License as published by the Free Software Foundation; either
  10. ;* version 2.1 of the License, or (at your option) any later version.
  11. ;*
  12. ;* Libav is distributed in the hope that it will be useful,
  13. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. ;* Lesser General Public License for more details.
  16. ;*
  17. ;* You should have received a copy of the GNU Lesser General Public
  18. ;* License along with Libav; if not, write to the Free Software
  19. ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. ;******************************************************************************
  21. %include "libavutil/x86/x86util.asm"
  22. SECTION_RODATA 32
  23. pf_s16_scale: times 4 dd 32753.0
  24. SECTION_TEXT
  25. ;------------------------------------------------------------------------------
  26. ; void ff_quantize(int16_t *dst, float *src, float *dither, int len);
  27. ;------------------------------------------------------------------------------
  28. INIT_XMM sse2
  29. cglobal quantize, 4,4,3, dst, src, dither, len
  30. lea lenq, [2*lend]
  31. add dstq, lenq
  32. lea srcq, [srcq+2*lenq]
  33. lea ditherq, [ditherq+2*lenq]
  34. neg lenq
  35. mova m2, [pf_s16_scale]
  36. .loop:
  37. mulps m0, m2, [srcq+2*lenq]
  38. mulps m1, m2, [srcq+2*lenq+mmsize]
  39. addps m0, [ditherq+2*lenq]
  40. addps m1, [ditherq+2*lenq+mmsize]
  41. cvtps2dq m0, m0
  42. cvtps2dq m1, m1
  43. packssdw m0, m1
  44. mova [dstq+lenq], m0
  45. add lenq, mmsize
  46. jl .loop
  47. REP_RET