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 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 "libavcodec/avcodec.h"
  23. #include "libavcodec/dsputil.h"
  24. #include "dsputil_sh4.h"
  25. #include "sh4.h"
  26. static void memzero_align8(void *dst,size_t size)
  27. {
  28. int fpscr;
  29. fp_single_enter(fpscr);
  30. dst = (char *)dst + size;
  31. size /= 32;
  32. __asm__ volatile (
  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. " fschg" //back to single
  44. : "+r"(dst),"+r"(size) :: "memory" );
  45. fp_single_leave(fpscr);
  46. }
  47. static void clear_blocks_sh4(DCTELEM *blocks)
  48. {
  49. memzero_align8(blocks,sizeof(DCTELEM)*6*64);
  50. }
  51. static void idct_put(uint8_t *dest, int line_size, DCTELEM *block)
  52. {
  53. int i;
  54. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  55. idct_sh4(block);
  56. for(i=0;i<8;i++) {
  57. dest[0] = cm[block[0]];
  58. dest[1] = cm[block[1]];
  59. dest[2] = cm[block[2]];
  60. dest[3] = cm[block[3]];
  61. dest[4] = cm[block[4]];
  62. dest[5] = cm[block[5]];
  63. dest[6] = cm[block[6]];
  64. dest[7] = cm[block[7]];
  65. dest+=line_size;
  66. block+=8;
  67. }
  68. }
  69. static void idct_add(uint8_t *dest, int line_size, DCTELEM *block)
  70. {
  71. int i;
  72. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  73. idct_sh4(block);
  74. for(i=0;i<8;i++) {
  75. dest[0] = cm[dest[0]+block[0]];
  76. dest[1] = cm[dest[1]+block[1]];
  77. dest[2] = cm[dest[2]+block[2]];
  78. dest[3] = cm[dest[3]+block[3]];
  79. dest[4] = cm[dest[4]+block[4]];
  80. dest[5] = cm[dest[5]+block[5]];
  81. dest[6] = cm[dest[6]+block[6]];
  82. dest[7] = cm[dest[7]+block[7]];
  83. dest+=line_size;
  84. block+=8;
  85. }
  86. }
  87. void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
  88. {
  89. const int idct_algo= avctx->idct_algo;
  90. const int high_bit_depth = avctx->bits_per_raw_sample > 8;
  91. dsputil_init_align(c,avctx);
  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 = idct_sh4;
  99. c->idct_permutation_type= FF_NO_IDCT_PERM;
  100. }
  101. }