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.

108 lines
3.3KB

  1. /*
  2. * sh4 dsputil
  3. *
  4. * Copyright (c) 2003 BERO <bero@geocities.co.jp>
  5. *
  6. * This file is part of Libav.
  7. *
  8. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "libavutil/attributes.h"
  23. #include "libavcodec/avcodec.h"
  24. #include "libavcodec/dsputil.h"
  25. #include "dsputil_sh4.h"
  26. #include "sh4.h"
  27. static void memzero_align8(void *dst,size_t size)
  28. {
  29. int fpscr;
  30. fp_single_enter(fpscr);
  31. dst = (char *)dst + size;
  32. size /= 32;
  33. __asm__ volatile (
  34. " fldi0 fr0\n"
  35. " fldi0 fr1\n"
  36. " fschg\n" // double
  37. "1: \n" \
  38. " dt %1\n"
  39. " fmov dr0,@-%0\n"
  40. " fmov dr0,@-%0\n"
  41. " fmov dr0,@-%0\n"
  42. " bf.s 1b\n"
  43. " fmov dr0,@-%0\n"
  44. " fschg" //back to single
  45. : "+r"(dst),"+r"(size) :: "memory" );
  46. fp_single_leave(fpscr);
  47. }
  48. static void clear_blocks_sh4(int16_t *blocks)
  49. {
  50. memzero_align8(blocks,sizeof(int16_t)*6*64);
  51. }
  52. static void idct_put(uint8_t *dest, int line_size, int16_t *block)
  53. {
  54. int i;
  55. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  56. ff_idct_sh4(block);
  57. for(i=0;i<8;i++) {
  58. dest[0] = cm[block[0]];
  59. dest[1] = cm[block[1]];
  60. dest[2] = cm[block[2]];
  61. dest[3] = cm[block[3]];
  62. dest[4] = cm[block[4]];
  63. dest[5] = cm[block[5]];
  64. dest[6] = cm[block[6]];
  65. dest[7] = cm[block[7]];
  66. dest+=line_size;
  67. block+=8;
  68. }
  69. }
  70. static void idct_add(uint8_t *dest, int line_size, int16_t *block)
  71. {
  72. int i;
  73. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  74. ff_idct_sh4(block);
  75. for(i=0;i<8;i++) {
  76. dest[0] = cm[dest[0]+block[0]];
  77. dest[1] = cm[dest[1]+block[1]];
  78. dest[2] = cm[dest[2]+block[2]];
  79. dest[3] = cm[dest[3]+block[3]];
  80. dest[4] = cm[dest[4]+block[4]];
  81. dest[5] = cm[dest[5]+block[5]];
  82. dest[6] = cm[dest[6]+block[6]];
  83. dest[7] = cm[dest[7]+block[7]];
  84. dest+=line_size;
  85. block+=8;
  86. }
  87. }
  88. av_cold void ff_dsputil_init_sh4(DSPContext *c, AVCodecContext *avctx)
  89. {
  90. const int idct_algo= avctx->idct_algo;
  91. const int high_bit_depth = avctx->bits_per_raw_sample > 8;
  92. if (!high_bit_depth)
  93. c->clear_blocks = clear_blocks_sh4;
  94. if (avctx->bits_per_raw_sample <= 8 &&
  95. (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) {
  96. c->idct_put = idct_put;
  97. c->idct_add = idct_add;
  98. c->idct = ff_idct_sh4;
  99. c->idct_permutation_type= FF_NO_IDCT_PERM;
  100. }
  101. }