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.

88 lines
2.8KB

  1. /*
  2. * Copyright (c) 2000,2001 Fabrice Bellard.
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. * MMI optimization by Leon van Stuivenberg
  19. */
  20. #include "../dsputil.h"
  21. #include "../mpegvideo.h"
  22. #include "../avcodec.h"
  23. static void dct_unquantize_h263_mmi(MpegEncContext *s,
  24. DCTELEM *block, int n, int qscale)
  25. {
  26. int level=0, qmul, qadd;
  27. int nCoeffs;
  28. assert(s->block_last_index[n]>=0);
  29. qadd = (qscale - 1) | 1;
  30. qmul = qscale << 1;
  31. if (s->mb_intra) {
  32. if (!s->h263_aic) {
  33. if (n < 4)
  34. level = block[0] * s->y_dc_scale;
  35. else
  36. level = block[0] * s->c_dc_scale;
  37. }else {
  38. qadd = 0;
  39. level = block[0];
  40. }
  41. nCoeffs= 63; //does not allways use zigzag table
  42. } else {
  43. nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
  44. }
  45. asm volatile(
  46. "add $14, $0, %3 \n\t"
  47. "pcpyld $8, %0, %0 \n\t"
  48. "pcpyh $8, $8 \n\t" //r8 = qmul
  49. "pcpyld $9, %1, %1 \n\t"
  50. "pcpyh $9, $9 \n\t" //r9 = qadd
  51. ".p2align 2 \n\t"
  52. "1: \n\t"
  53. "lq $10, 0($14) \n\t" //r10 = level
  54. "addi $14, $14, 16 \n\t" //block+=8
  55. "addi %2, %2, -8 \n\t"
  56. "pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0
  57. "pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0
  58. "por $12, $11, $12 \n\t"
  59. "pmulth $10, $10, $8 \n\t"
  60. "paddh $13, $9, $11 \n\t"
  61. "pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
  62. "pmfhl.uw $11 \n\t"
  63. "pinteh $10, $11, $10 \n\t" //r10 = level * qmul
  64. "paddh $10, $10, $13 \n\t"
  65. "pand $10, $10, $12 \n\t"
  66. "sq $10, -16($14) \n\t"
  67. "bgez %2, 1b \n\t"
  68. :: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
  69. if(s->mb_intra)
  70. block[0]= level;
  71. }
  72. void MPV_common_init_mmi(MpegEncContext *s)
  73. {
  74. s->dct_unquantize_h263_intra =
  75. s->dct_unquantize_h263_inter = dct_unquantize_h263_mmi;
  76. }