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.

152 lines
4.4KB

  1. /*
  2. * Sun mediaLib optimized DSP utils
  3. * Copyright (c) 2001 Fabrice Bellard.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include "../dsputil.h"
  20. #include "../mpegvideo.h"
  21. #include <mlib_types.h>
  22. #include <mlib_status.h>
  23. #include <mlib_sys.h>
  24. #include <mlib_video.h>
  25. static void put_pixels_mlib (uint8_t * dest, const uint8_t * ref,
  26. int stride, int height)
  27. {
  28. assert(height == 16 || height == 8);
  29. if (height == 16)
  30. mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride);
  31. else
  32. mlib_VideoCopyRef_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
  33. }
  34. static void put_pixels_x2_mlib (uint8_t * dest, const uint8_t * ref,
  35. int stride, int height)
  36. {
  37. assert(height == 16 || height == 8);
  38. if (height == 16)
  39. mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
  40. else
  41. mlib_VideoInterpX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
  42. }
  43. static void put_pixels_y2_mlib (uint8_t * dest, const uint8_t * ref,
  44. int stride, int height)
  45. {
  46. assert(height == 16 || height == 8);
  47. if (height == 16)
  48. mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
  49. else
  50. mlib_VideoInterpY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
  51. }
  52. static void put_pixels_xy2_mlib(uint8_t * dest, const uint8_t * ref,
  53. int stride, int height)
  54. {
  55. assert(height == 16 || height == 8);
  56. if (height == 16)
  57. mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
  58. else
  59. mlib_VideoInterpXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
  60. }
  61. static void avg_pixels_mlib (uint8_t * dest, const uint8_t * ref,
  62. int stride, int height)
  63. {
  64. assert(height == 16 || height == 8);
  65. if (height == 16)
  66. mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride);
  67. else
  68. mlib_VideoCopyRefAve_U8_U8_8x8 (dest, (uint8_t *)ref, stride);
  69. }
  70. static void avg_pixels_x2_mlib (uint8_t * dest, const uint8_t * ref,
  71. int stride, int height)
  72. {
  73. assert(height == 16 || height == 8);
  74. if (height == 16)
  75. mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
  76. else
  77. mlib_VideoInterpAveX_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
  78. }
  79. static void avg_pixels_y2_mlib (uint8_t * dest, const uint8_t * ref,
  80. int stride, int height)
  81. {
  82. assert(height == 16 || height == 8);
  83. if (height == 16)
  84. mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
  85. else
  86. mlib_VideoInterpAveY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
  87. }
  88. static void avg_pixels_xy2_mlib (uint8_t * dest, const uint8_t * ref,
  89. int stride, int height)
  90. {
  91. assert(height == 16 || height == 8);
  92. if (height == 16)
  93. mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
  94. else
  95. mlib_VideoInterpAveXY_U8_U8_8x8 (dest, (uint8_t *)ref, stride, stride);
  96. }
  97. static void add_pixels_clamped_mlib(const DCTELEM *block, UINT8 *pixels, int line_size)
  98. {
  99. mlib_VideoAddBlock_U8_S16(pixels, (mlib_s16 *)block, line_size);
  100. }
  101. void ff_idct_mlib(DCTELEM *data)
  102. {
  103. mlib_VideoIDCT8x8_S16_S16 (data, data);
  104. }
  105. void ff_fdct_mlib(DCTELEM *data)
  106. {
  107. mlib_VideoDCT8x8_S16_S16 (data, data);
  108. }
  109. void dsputil_init_mlib(void)
  110. {
  111. ff_idct = ff_idct_mlib;
  112. put_pixels_tab[1][0] = put_pixels_mlib;
  113. put_pixels_tab[1][1] = put_pixels_x2_mlib;
  114. put_pixels_tab[1][2] = put_pixels_y2_mlib;
  115. put_pixels_tab[1][3] = put_pixels_xy2_mlib;
  116. avg_pixels_tab[1][0] = avg_pixels_mlib;
  117. avg_pixels_tab[1][1] = avg_pixels_x2_mlib;
  118. avg_pixels_tab[1][2] = avg_pixels_y2_mlib;
  119. avg_pixels_tab[1][3] = avg_pixels_xy2_mlib;
  120. put_no_rnd_pixels_tab[1][0] = put_pixels_mlib;
  121. add_pixels_clamped = add_pixels_clamped_mlib;
  122. }
  123. void MPV_common_init_mlib(MpegEncContext *s)
  124. {
  125. if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
  126. s->fdct = ff_fdct_mlib;
  127. }
  128. }