mpegvideo_iwmmxt.c 5.0 KB

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