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.

119 lines
3.5KB

  1. /*
  2. * MMI optimized DSP utils
  3. * Copyright (c) 2000, 2001 Fabrice Bellard.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library 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 GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. * MMI optimization by Leon van Stuivenberg <leonvs@iae.nl>
  20. */
  21. #include "../dsputil.h"
  22. #include "mmi.h"
  23. static void clear_blocks_mmi(DCTELEM * blocks)
  24. {
  25. int i;
  26. for (i = 0; i < 6; i++) {
  27. asm volatile(
  28. "sq $0, 0(%0) \n\t"
  29. "sq $0, 16(%0) \n\t"
  30. "sq $0, 32(%0) \n\t"
  31. "sq $0, 48(%0) \n\t"
  32. "sq $0, 64(%0) \n\t"
  33. "sq $0, 80(%0) \n\t"
  34. "sq $0, 96(%0) \n\t"
  35. "sq $0, 112(%0) \n\t" :: "r" (blocks) : "memory" );
  36. blocks += 64;
  37. }
  38. }
  39. static void get_pixels_mmi(DCTELEM *block, const UINT8 *pixels, int line_size)
  40. {
  41. int i;
  42. for(i=0;i<8;i++) {
  43. asm volatile(
  44. ".set push \n\t"
  45. ".set mips3 \n\t"
  46. "ld $8, 0(%1) \n\t"
  47. "add %1, %1, %2 \n\t"
  48. "pextlb $8, $0, $8 \n\t"
  49. "sq $8, 0(%0) \n\t"
  50. ".set pop \n\t"
  51. :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "memory" );
  52. block += 8;
  53. }
  54. }
  55. static void put_pixels8_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
  56. {
  57. int i;
  58. for(i=0; i<h; i++) {
  59. asm volatile(
  60. ".set push \n\t"
  61. ".set mips3 \n\t"
  62. "ldr $8, 0(%1) \n\t"
  63. "ldl $8, 7(%1) \n\t"
  64. "add %1, %1, %2 \n\t"
  65. "sd $8, 0(%0) \n\t"
  66. "add %0, %0, %2 \n\t"
  67. ".set pop \n\t"
  68. :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "memory" );
  69. }
  70. }
  71. static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
  72. {
  73. int i;
  74. for(i=0; i<(h>>2); i++) {
  75. asm volatile (
  76. ".set push \n\t"
  77. ".set mips3 \n\t"
  78. #define PUTPIX16 \
  79. "ldr $8, 0(%1) \n\t" \
  80. "ldl $8, 7(%1) \n\t" \
  81. "ldr $9, 8(%1) \n\t" \
  82. "ldl $9, 15(%1) \n\t" \
  83. "add %1, %1, %2 \n\t" \
  84. "pcpyld $8, $9, $8 \n\t" \
  85. "sq $8, 0(%0) \n\t" \
  86. "add %0, %0, %2 \n\t"
  87. PUTPIX16
  88. PUTPIX16
  89. PUTPIX16
  90. PUTPIX16
  91. ".set pop \n\t"
  92. :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "$9", "memory" );
  93. }
  94. }
  95. void dsputil_init_mmi(DSPContext* c, unsigned mask)
  96. {
  97. c->clear_blocks = clear_blocks_mmi;
  98. c->put_pixels_tab[1][0] = put_pixels8_mmi;
  99. c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;
  100. c->put_pixels_tab[0][0] = put_pixels16_mmi;
  101. c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
  102. c->get_pixels = get_pixels_mmi;
  103. }