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.

97 lines
2.9KB

  1. /*
  2. * Alpha optimized DSP utils
  3. * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
  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. #include "asm.h"
  20. #include "../dsputil.h"
  21. #include "../mpegvideo.h"
  22. static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block,
  23. int n, int qscale)
  24. {
  25. int i, n_coeffs;
  26. uint64_t qmul, qadd;
  27. uint64_t correction;
  28. DCTELEM *orig_block = block;
  29. DCTELEM block0;
  30. qadd = WORD_VEC((qscale - 1) | 1);
  31. qmul = qscale << 1;
  32. /* This mask kills spill from negative subwords to the next subword. */
  33. correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
  34. if (s->mb_intra) {
  35. if (!s->h263_aic) {
  36. if (n < 4)
  37. block0 = block[0] * s->y_dc_scale;
  38. else
  39. block0 = block[0] * s->c_dc_scale;
  40. } else {
  41. qadd = 0;
  42. }
  43. n_coeffs = 63; // does not always use zigzag table
  44. } else {
  45. n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
  46. }
  47. for(i = 0; i <= n_coeffs; block += 4, i += 4) {
  48. uint64_t levels, negmask, zeros, add;
  49. levels = ldq(block);
  50. if (levels == 0)
  51. continue;
  52. #ifdef __alpha_max__
  53. /* I don't think the speed difference justifies runtime
  54. detection. */
  55. negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
  56. negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
  57. #else
  58. negmask = cmpbge(WORD_VEC(0x7fff), levels);
  59. negmask &= (negmask >> 1) | (1 << 7);
  60. negmask = zap(-1, negmask);
  61. #endif
  62. zeros = cmpbge(0, levels);
  63. zeros &= zeros >> 1;
  64. /* zeros |= zeros << 1 is not needed since qadd <= 255, so
  65. zapping the lower byte suffices. */
  66. levels *= qmul;
  67. levels -= correction & (negmask << 16);
  68. /* Negate qadd for negative levels. */
  69. add = qadd ^ negmask;
  70. add += WORD_VEC(0x0001) & negmask;
  71. /* Set qadd to 0 for levels == 0. */
  72. add = zap(add, zeros);
  73. levels += add;
  74. stq(levels, block);
  75. }
  76. if (s->mb_intra && !s->h263_aic)
  77. orig_block[0] = block0;
  78. }
  79. void MPV_common_init_axp(MpegEncContext *s)
  80. {
  81. s->dct_unquantize_h263 = dct_unquantize_h263_axp;
  82. }