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.

93 lines
3.5KB

  1. /*
  2. * Copyright (C) 2010 Mans Rullgard <mans@mansr.com>
  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. #ifndef AVCODEC_ARM_VP56_ARITH_H
  21. #define AVCODEC_ARM_VP56_ARITH_H
  22. #if HAVE_ARMV6 && HAVE_INLINE_ASM
  23. #define vp56_rac_get_prob vp56_rac_get_prob_armv6
  24. static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr)
  25. {
  26. unsigned shift = ff_vp56_norm_shift[c->high];
  27. unsigned code_word = c->code_word << shift;
  28. unsigned high = c->high << shift;
  29. unsigned bit;
  30. __asm__ volatile ("adds %3, %3, %0 \n"
  31. "cmpcs %7, %4 \n"
  32. "ldrcsh %2, [%4], #2 \n"
  33. "rsb %0, %6, #256 \n"
  34. "smlabb %0, %5, %6, %0 \n"
  35. "rev16cs %2, %2 \n"
  36. "orrcs %1, %1, %2, lsl %3 \n"
  37. "subcs %3, %3, #16 \n"
  38. "lsr %0, %0, #8 \n"
  39. "cmp %1, %0, lsl #16 \n"
  40. "subge %1, %1, %0, lsl #16 \n"
  41. "subge %0, %5, %0 \n"
  42. "movge %2, #1 \n"
  43. "movlt %2, #0 \n"
  44. : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit),
  45. "+&r"(c->bits), "+&r"(c->buffer)
  46. : "r"(high), "r"(pr), "r"(c->end - 1),
  47. "0"(shift), "1"(code_word));
  48. return bit;
  49. }
  50. #define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6
  51. static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr)
  52. {
  53. unsigned shift = ff_vp56_norm_shift[c->high];
  54. unsigned code_word = c->code_word << shift;
  55. unsigned high = c->high << shift;
  56. unsigned low;
  57. unsigned tmp;
  58. __asm__ volatile ("adds %3, %3, %0 \n"
  59. "cmpcs %7, %4 \n"
  60. "ldrcsh %2, [%4], #2 \n"
  61. "rsb %0, %6, #256 \n"
  62. "smlabb %0, %5, %6, %0 \n"
  63. "rev16cs %2, %2 \n"
  64. "orrcs %1, %1, %2, lsl %3 \n"
  65. "subcs %3, %3, #16 \n"
  66. "lsr %0, %0, #8 \n"
  67. "lsl %2, %0, #16 \n"
  68. : "=&r"(low), "+&r"(code_word), "=&r"(tmp),
  69. "+&r"(c->bits), "+&r"(c->buffer)
  70. : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift));
  71. if (code_word >= tmp) {
  72. c->high = high - low;
  73. c->code_word = code_word - tmp;
  74. return 1;
  75. }
  76. c->high = low;
  77. c->code_word = code_word;
  78. return 0;
  79. }
  80. #endif
  81. #endif