vc1_pred.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * VC-1 and WMV3 decoder
  3. * Copyright (c) 2006-2007 Konstantin Shishkov
  4. * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer
  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. #ifndef AVCODEC_VC1_PRED_H
  23. #define AVCODEC_VC1_PRED_H
  24. #include "vc1.h"
  25. #include "vc1data.h"
  26. void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
  27. int mv1, int r_x, int r_y, uint8_t* is_intra,
  28. int pred_flag, int dir);
  29. void ff_vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y,
  30. int mvn, int r_x, int r_y, uint8_t* is_intra,
  31. int dir);
  32. void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
  33. int direct, int mvtype);
  34. void ff_vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y,
  35. int mv1, int *pred_flag);
  36. static av_always_inline int scale_mv(int value, int bfrac, int inv, int qs)
  37. {
  38. int n = bfrac;
  39. #if B_FRACTION_DEN==256
  40. if (inv)
  41. n -= 256;
  42. if (!qs)
  43. return 2 * ((value * n + 255) >> 9);
  44. return (value * n + 128) >> 8;
  45. #else
  46. if (inv)
  47. n -= B_FRACTION_DEN;
  48. if (!qs)
  49. return 2 * ((value * n + B_FRACTION_DEN - 1) / (2 * B_FRACTION_DEN));
  50. return (value * n + B_FRACTION_DEN/2) / B_FRACTION_DEN;
  51. #endif
  52. }
  53. #endif /* AVCODEC_VC1_PRED_H */