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.

55 lines
1.7KB

  1. /**
  2. * VP5 and VP6 compatible video decoder (arith decoder)
  3. *
  4. * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
  5. * Copyright (C) 2010 Eli Friedman
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVCODEC_X86_VP56_ARITH_H
  24. #define AVCODEC_X86_VP56_ARITH_H
  25. #if HAVE_FAST_CMOV
  26. #define vp56_rac_get_prob vp56_rac_get_prob
  27. static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
  28. {
  29. unsigned int code_word = vp56_rac_renorm(c);
  30. unsigned int high = c->high;
  31. unsigned int low = 1 + (((high - 1) * prob) >> 8);
  32. unsigned int low_shift = low << 16;
  33. int bit = 0;
  34. __asm__(
  35. "subl %4, %1 \n\t"
  36. "subl %3, %2 \n\t"
  37. "leal (%2, %3), %3 \n\t"
  38. "setae %b0 \n\t"
  39. "cmovb %4, %1 \n\t"
  40. "cmovb %3, %2 \n\t"
  41. : "+q"(bit), "+r"(high), "+r"(code_word), "+r"(low_shift)
  42. : "r"(low)
  43. );
  44. c->high = high;
  45. c->code_word = code_word;
  46. return bit;
  47. }
  48. #endif
  49. #endif /* AVCODEC_X86_VP56_ARITH_H */