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.

121 lines
3.6KB

  1. /*
  2. * sh4 dsputil
  3. *
  4. * Copyright (c) 2003 BERO <bero@geocities.co.jp>
  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. #include "../avcodec.h"
  23. #include "../dsputil.h"
  24. static void memzero_align8(void *dst,size_t size)
  25. {
  26. #if defined(__SH4__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
  27. (char*)dst+=size;
  28. size/=8*4;
  29. asm(
  30. #if defined(__SH4__)
  31. " fschg\n" //single float mode
  32. #endif
  33. " fldi0 fr0\n"
  34. " fldi0 fr1\n"
  35. " fschg\n" // double
  36. "1: \n" \
  37. " dt %1\n"
  38. " fmov dr0,@-%0\n"
  39. " fmov dr0,@-%0\n"
  40. " fmov dr0,@-%0\n"
  41. " bf.s 1b\n"
  42. " fmov dr0,@-%0\n"
  43. #if defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
  44. " fschg" //back to single
  45. #endif
  46. : : "r"(dst),"r"(size): "memory" );
  47. #else
  48. double *d = dst;
  49. size/=8*4;
  50. do {
  51. d[0] = 0.0;
  52. d[1] = 0.0;
  53. d[2] = 0.0;
  54. d[3] = 0.0;
  55. d+=4;
  56. } while(--size);
  57. #endif
  58. }
  59. static void clear_blocks_sh4(DCTELEM *blocks)
  60. {
  61. // if (((int)blocks&7)==0)
  62. memzero_align8(blocks,sizeof(DCTELEM)*6*64);
  63. }
  64. extern void idct_sh4(DCTELEM *block);
  65. static void idct_put(uint8_t *dest, int line_size, DCTELEM *block)
  66. {
  67. idct_sh4(block);
  68. int i;
  69. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  70. for(i=0;i<8;i++) {
  71. dest[0] = cm[block[0]];
  72. dest[1] = cm[block[1]];
  73. dest[2] = cm[block[2]];
  74. dest[3] = cm[block[3]];
  75. dest[4] = cm[block[4]];
  76. dest[5] = cm[block[5]];
  77. dest[6] = cm[block[6]];
  78. dest[7] = cm[block[7]];
  79. dest+=line_size;
  80. block+=8;
  81. }
  82. }
  83. static void idct_add(uint8_t *dest, int line_size, DCTELEM *block)
  84. {
  85. idct_sh4(block);
  86. int i;
  87. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  88. for(i=0;i<8;i++) {
  89. dest[0] = cm[dest[0]+block[0]];
  90. dest[1] = cm[dest[1]+block[1]];
  91. dest[2] = cm[dest[2]+block[2]];
  92. dest[3] = cm[dest[3]+block[3]];
  93. dest[4] = cm[dest[4]+block[4]];
  94. dest[5] = cm[dest[5]+block[5]];
  95. dest[6] = cm[dest[6]+block[6]];
  96. dest[7] = cm[dest[7]+block[7]];
  97. dest+=line_size;
  98. block+=8;
  99. }
  100. }
  101. extern void dsputil_init_align(DSPContext* c, AVCodecContext *avctx);
  102. void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
  103. {
  104. const int idct_algo= avctx->idct_algo;
  105. dsputil_init_align(c,avctx);
  106. c->clear_blocks = clear_blocks_sh4;
  107. if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){
  108. c->idct_put = idct_put;
  109. c->idct_add = idct_add;
  110. c->idct = idct_sh4;
  111. c->idct_permutation_type= FF_NO_IDCT_PERM; //FF_SIMPLE_IDCT_PERM; //FF_LIBMPEG2_IDCT_PERM;
  112. }
  113. }