dsputil_sh4.c
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:3k
源码类别:

Windows CE

开发平台:

C/C++

  1. /*
  2.  *  sh4 dsputil
  3.  *
  4.  * Copyright (c) 2003 BERO <bero@geocities.co.jp>
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the Free Software
  18.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  */
  20. #include "../avcodec.h"
  21. #include "../dsputil.h"
  22. static void memzero_align8(void *dst,size_t size)
  23. {
  24. #if defined(__SH4__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
  25. (char*)dst+=size;
  26. size/=8*4;
  27. asm(
  28. #if defined(__SH4__)
  29. " fschgn"  //single float mode
  30. #endif
  31. " fldi0 fr0n"
  32. " fldi0 fr1n"
  33. " fschgn"  // double
  34. "1: n" 
  35. " dt %1n"
  36. " fmov dr0,@-%0n"
  37. " fmov dr0,@-%0n"
  38. " fmov dr0,@-%0n"
  39. " bf.s 1bn"
  40. " fmov dr0,@-%0n"
  41. #if defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
  42. " fschg" //back to single
  43. #endif
  44. : : "r"(dst),"r"(size): "memory" );
  45. #else
  46. double *d = dst;
  47. size/=8*4;
  48. do {
  49. d[0] = 0.0;
  50. d[1] = 0.0;
  51. d[2] = 0.0;
  52. d[3] = 0.0;
  53. d+=4;
  54. } while(--size);
  55. #endif
  56. }
  57. static void clear_blocks_sh4(DCTELEM *blocks)
  58. {
  59. // if (((int)blocks&7)==0) 
  60. memzero_align8(blocks,sizeof(DCTELEM)*6*64);
  61. }
  62. extern void idct_sh4(DCTELEM *block);
  63. static void idct_put(uint8_t *dest, int line_size, DCTELEM *block)
  64. {
  65. idct_sh4(block);
  66. int i;
  67. uint8_t *cm = cropTbl + MAX_NEG_CROP;
  68. for(i=0;i<8;i++) {
  69. dest[0] = cm[block[0]];
  70. dest[1] = cm[block[1]];
  71. dest[2] = cm[block[2]];
  72. dest[3] = cm[block[3]];
  73. dest[4] = cm[block[4]];
  74. dest[5] = cm[block[5]];
  75. dest[6] = cm[block[6]];
  76. dest[7] = cm[block[7]];
  77. dest+=line_size;
  78. block+=8;
  79. }
  80. }
  81. static void idct_add(uint8_t *dest, int line_size, DCTELEM *block)
  82. {
  83. idct_sh4(block);
  84. int i;
  85. uint8_t *cm = cropTbl + MAX_NEG_CROP;
  86. for(i=0;i<8;i++) {
  87. dest[0] = cm[dest[0]+block[0]];
  88. dest[1] = cm[dest[1]+block[1]];
  89. dest[2] = cm[dest[2]+block[2]];
  90. dest[3] = cm[dest[3]+block[3]];
  91. dest[4] = cm[dest[4]+block[4]];
  92. dest[5] = cm[dest[5]+block[5]];
  93. dest[6] = cm[dest[6]+block[6]];
  94. dest[7] = cm[dest[7]+block[7]];
  95. dest+=line_size;
  96. block+=8;
  97. }
  98. }
  99. extern void dsputil_init_align(DSPContext* c, AVCodecContext *avctx);
  100. void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
  101. {
  102. const int idct_algo= avctx->idct_algo;
  103. dsputil_init_align(c,avctx);
  104. c->clear_blocks = clear_blocks_sh4;
  105. if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){        
  106. c->idct_put = idct_put;
  107. c->idct_add = idct_add;
  108.                c->idct     = idct_sh4;
  109. c->idct_permutation_type= FF_NO_IDCT_PERM; //FF_SIMPLE_IDCT_PERM; //FF_LIBMPEG2_IDCT_PERM;
  110. }
  111. }