scene_sad.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /**
  19. * @file
  20. * Scene SAD functions
  21. */
  22. #include "scene_sad.h"
  23. void ff_scene_sad16_c(SCENE_SAD_PARAMS)
  24. {
  25. uint64_t sad = 0;
  26. const uint16_t *src1w = (const uint16_t *)src1;
  27. const uint16_t *src2w = (const uint16_t *)src2;
  28. int x, y;
  29. stride1 /= 2;
  30. stride2 /= 2;
  31. for (y = 0; y < height; y++) {
  32. for (x = 0; x < width; x++)
  33. sad += FFABS(src1w[x] - src2w[x]);
  34. src1w += stride1;
  35. src2w += stride2;
  36. }
  37. *sum = sad;
  38. }
  39. void ff_scene_sad_c(SCENE_SAD_PARAMS)
  40. {
  41. uint64_t sad = 0;
  42. int x, y;
  43. for (y = 0; y < height; y++) {
  44. for (x = 0; x < width; x++)
  45. sad += FFABS(src1[x] - src2[x]);
  46. src1 += stride1;
  47. src2 += stride2;
  48. }
  49. *sum = sad;
  50. }
  51. ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
  52. {
  53. ff_scene_sad_fn sad = NULL;
  54. if (ARCH_X86)
  55. sad = ff_scene_sad_get_fn_x86(depth);
  56. if (!sad) {
  57. if (depth == 8)
  58. sad = ff_scene_sad_c;
  59. if (depth == 16)
  60. sad = ff_scene_sad16_c;
  61. }
  62. return sad;
  63. }