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.

66 lines
2.0KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg 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.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <assert.h>
  19. #include <stdint.h>
  20. #include "config.h"
  21. #include "libavutil/avassert.h"
  22. #include "libavutil/attributes.h"
  23. #include "avcodec.h"
  24. #include "mpegvideoencdsp.h"
  25. static int try_8x8basis_c(int16_t rem[64], int16_t weight[64],
  26. int16_t basis[64], int scale)
  27. {
  28. int i;
  29. unsigned int sum = 0;
  30. for (i = 0; i < 8 * 8; i++) {
  31. int b = rem[i] + ((basis[i] * scale +
  32. (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
  33. (BASIS_SHIFT - RECON_SHIFT));
  34. int w = weight[i];
  35. b >>= RECON_SHIFT;
  36. av_assert2(-512 < b && b < 512);
  37. sum += (w * b) * (w * b) >> 4;
  38. }
  39. return sum >> 2;
  40. }
  41. static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale)
  42. {
  43. int i;
  44. for (i = 0; i < 8 * 8; i++)
  45. rem[i] += (basis[i] * scale +
  46. (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
  47. (BASIS_SHIFT - RECON_SHIFT);
  48. }
  49. av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c,
  50. AVCodecContext *avctx)
  51. {
  52. c->try_8x8basis = try_8x8basis_c;
  53. c->add_8x8basis = add_8x8basis_c;
  54. if (ARCH_X86)
  55. ff_mpegvideoencdsp_init_x86(c, avctx);
  56. }