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.

118 lines
5.0KB

  1. /*
  2. * copyright (c) 2004 AGAWA Koji
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "../dsputil.h"
  19. #include "../mpegvideo.h"
  20. #include "../avcodec.h"
  21. static void dct_unquantize_h263_intra_iwmmxt(MpegEncContext *s,
  22. DCTELEM *block, int n, int qscale)
  23. {
  24. int level, qmul, qadd;
  25. int nCoeffs;
  26. DCTELEM *block_orig = block;
  27. assert(s->block_last_index[n]>=0);
  28. qmul = qscale << 1;
  29. if (!s->h263_aic) {
  30. if (n < 4)
  31. level = block[0] * s->y_dc_scale;
  32. else
  33. level = block[0] * s->c_dc_scale;
  34. qadd = (qscale - 1) | 1;
  35. }else{
  36. qadd = 0;
  37. level = block[0];
  38. }
  39. if(s->ac_pred)
  40. nCoeffs=63;
  41. else
  42. nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
  43. __asm__ __volatile__ (
  44. /* "movd %1, %%mm6 \n\t" //qmul */
  45. /* "packssdw %%mm6, %%mm6 \n\t" */
  46. /* "packssdw %%mm6, %%mm6 \n\t" */
  47. "tbcsth wr6, %[qmul] \n\t"
  48. /* "movd %2, %%mm5 \n\t" //qadd */
  49. /* "packssdw %%mm5, %%mm5 \n\t" */
  50. /* "packssdw %%mm5, %%mm5 \n\t" */
  51. "tbcsth wr5, %[qadd] \n\t"
  52. "wzero wr7 \n\t" /* "pxor %%mm7, %%mm7 \n\t" */
  53. "wzero wr4 \n\t" /* "pxor %%mm4, %%mm4 \n\t" */
  54. "wsubh wr7, wr5, wr7 \n\t" /* "psubw %%mm5, %%mm7 \n\t" */
  55. "1: \n\t"
  56. "wldrd wr2, [%[block]] \n\t" /* "movq (%0, %3), %%mm0 \n\t" */
  57. "wldrd wr3, [%[block], #8] \n\t" /* "movq 8(%0, %3), %%mm1 \n\t" */
  58. "wmulsl wr0, wr6, wr2 \n\t" /* "pmullw %%mm6, %%mm0 \n\t" */
  59. "wmulsl wr1, wr6, wr3 \n\t" /* "pmullw %%mm6, %%mm1 \n\t" */
  60. /* "movq (%0, %3), %%mm2 \n\t" */
  61. /* "movq 8(%0, %3), %%mm3 \n\t" */
  62. "wcmpgtsh wr2, wr4, wr2 \n\t" /* "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 */
  63. "wcmpgtsh wr3, wr4, wr2 \n\t" /* "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 */
  64. "wxor wr0, wr2, wr0 \n\t" /* "pxor %%mm2, %%mm0 \n\t" */
  65. "wxor wr1, wr3, wr1 \n\t" /* "pxor %%mm3, %%mm1 \n\t" */
  66. "waddh wr0, wr7, wr0 \n\t" /* "paddw %%mm7, %%mm0 \n\t" */
  67. "waddh wr1, wr7, wr1 \n\t" /* "paddw %%mm7, %%mm1 \n\t" */
  68. "wxor wr2, wr0, wr2 \n\t" /* "pxor %%mm0, %%mm2 \n\t" */
  69. "wxor wr3, wr1, wr3 \n\t" /* "pxor %%mm1, %%mm3 \n\t" */
  70. "wcmpeqh wr0, wr7, wr0 \n\t" /* "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0 */
  71. "wcmpeqh wr1, wr7, wr1 \n\t" /* "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0 */
  72. "wandn wr0, wr2, wr0 \n\t" /* "pandn %%mm2, %%mm0 \n\t" */
  73. "wandn wr1, wr3, wr1 \n\t" /* "pandn %%mm3, %%mm1 \n\t" */
  74. "wstrd wr0, [%[block]] \n\t" /* "movq %%mm0, (%0, %3) \n\t" */
  75. "wstrd wr1, [%[block], #8] \n\t" /* "movq %%mm1, 8(%0, %3) \n\t" */
  76. "add %[block], %[block], #16 \n\t" /* "addl $16, %3 \n\t" */
  77. "subs %[i], %[i], #1 \n\t"
  78. "bne 1b \n\t" /* "jng 1b \n\t" */
  79. :[block]"+r"(block)
  80. :[i]"r"((nCoeffs + 8) / 8), [qmul]"r"(qmul), [qadd]"r"(qadd)
  81. :"memory");
  82. block_orig[0] = level;
  83. }
  84. #if 0
  85. static void dct_unquantize_h263_inter_iwmmxt(MpegEncContext *s,
  86. DCTELEM *block, int n, int qscale)
  87. {
  88. int nCoeffs;
  89. assert(s->block_last_index[n]>=0);
  90. if(s->ac_pred)
  91. nCoeffs=63;
  92. else
  93. nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
  94. ippiQuantInvInter_Compact_H263_16s_I(block, nCoeffs+1, qscale);
  95. }
  96. #endif
  97. void MPV_common_init_iwmmxt(MpegEncContext *s)
  98. {
  99. if (!(mm_flags & MM_IWMMXT)) return;
  100. s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_iwmmxt;
  101. #if 0
  102. s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_iwmmxt;
  103. #endif
  104. }