blockdsp.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <stdint.h>
  19. #include <string.h>
  20. #include "config.h"
  21. #include "libavutil/attributes.h"
  22. #include "avcodec.h"
  23. #include "blockdsp.h"
  24. static void clear_block_c(int16_t *block)
  25. {
  26. memset(block, 0, sizeof(int16_t) * 64);
  27. }
  28. static void clear_blocks_c(int16_t *blocks)
  29. {
  30. memset(blocks, 0, sizeof(int16_t) * 6 * 64);
  31. }
  32. static void fill_block16_c(uint8_t *block, uint8_t value, ptrdiff_t line_size,
  33. int h)
  34. {
  35. int i;
  36. for (i = 0; i < h; i++) {
  37. memset(block, value, 16);
  38. block += line_size;
  39. }
  40. }
  41. static void fill_block8_c(uint8_t *block, uint8_t value, ptrdiff_t line_size,
  42. int h)
  43. {
  44. int i;
  45. for (i = 0; i < h; i++) {
  46. memset(block, value, 8);
  47. block += line_size;
  48. }
  49. }
  50. av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
  51. {
  52. c->clear_block = clear_block_c;
  53. c->clear_blocks = clear_blocks_c;
  54. c->fill_block_tab[0] = fill_block16_c;
  55. c->fill_block_tab[1] = fill_block8_c;
  56. #if ARCH_ALPHA
  57. ff_blockdsp_init_alpha(c);
  58. #elif ARCH_ARM
  59. ff_blockdsp_init_arm(c);
  60. #elif ARCH_PPC
  61. ff_blockdsp_init_ppc(c);
  62. #elif ARCH_X86
  63. ff_blockdsp_init_x86(c, avctx);
  64. #elif ARCH_MIPS
  65. ff_blockdsp_init_mips(c);
  66. #endif
  67. }