mpegvideo_mmi.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2000,2001 Fabrice Bellard
  3. *
  4. * MMI optimization by Leon van Stuivenberg
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "libavcodec/avcodec.h"
  23. #include "libavcodec/dsputil.h"
  24. #include "libavcodec/mpegvideo.h"
  25. static void dct_unquantize_h263_mmi(MpegEncContext *s,
  26. DCTELEM *block, int n, int qscale)
  27. {
  28. int level=0, qmul, qadd;
  29. int nCoeffs;
  30. assert(s->block_last_index[n]>=0);
  31. qadd = (qscale - 1) | 1;
  32. qmul = qscale << 1;
  33. if (s->mb_intra) {
  34. if (!s->h263_aic) {
  35. if (n < 4)
  36. level = block[0] * s->y_dc_scale;
  37. else
  38. level = block[0] * s->c_dc_scale;
  39. }else {
  40. qadd = 0;
  41. level = block[0];
  42. }
  43. nCoeffs= 63; //does not always use zigzag table
  44. } else {
  45. nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
  46. }
  47. __asm__ volatile(
  48. "add $14, $0, %3 \n\t"
  49. "pcpyld $8, %0, %0 \n\t"
  50. "pcpyh $8, $8 \n\t" //r8 = qmul
  51. "pcpyld $9, %1, %1 \n\t"
  52. "pcpyh $9, $9 \n\t" //r9 = qadd
  53. ".p2align 2 \n\t"
  54. "1: \n\t"
  55. "lq $10, 0($14) \n\t" //r10 = level
  56. "addi $14, $14, 16 \n\t" //block+=8
  57. "addi %2, %2, -8 \n\t"
  58. "pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0
  59. "pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0
  60. "por $12, $11, $12 \n\t"
  61. "pmulth $10, $10, $8 \n\t"
  62. "paddh $13, $9, $11 \n\t"
  63. "pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
  64. "pmfhl.uw $11 \n\t"
  65. "pinteh $10, $11, $10 \n\t" //r10 = level * qmul
  66. "paddh $10, $10, $13 \n\t"
  67. "pand $10, $10, $12 \n\t"
  68. "sq $10, -16($14) \n\t"
  69. "bgez %2, 1b \n\t"
  70. :: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
  71. if(s->mb_intra)
  72. block[0]= level;
  73. }
  74. void MPV_common_init_mmi(MpegEncContext *s)
  75. {
  76. s->dct_unquantize_h263_intra =
  77. s->dct_unquantize_h263_inter = dct_unquantize_h263_mmi;
  78. }