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.

334 lines
10KB

  1. /*
  2. * thirdpel DSP functions
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav 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 Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * thirdpel DSP functions
  23. */
  24. #include <stdint.h>
  25. #include "libavutil/attributes.h"
  26. #include "tpeldsp.h"
  27. #define BIT_DEPTH 8
  28. #include "pel_template.c"
  29. static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
  30. int stride, int width, int height)
  31. {
  32. switch (width) {
  33. case 2:
  34. put_pixels2_8_c(dst, src, stride, height);
  35. break;
  36. case 4:
  37. put_pixels4_8_c(dst, src, stride, height);
  38. break;
  39. case 8:
  40. put_pixels8_8_c(dst, src, stride, height);
  41. break;
  42. case 16:
  43. put_pixels16_8_c(dst, src, stride, height);
  44. break;
  45. }
  46. }
  47. static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
  48. int stride, int width, int height)
  49. {
  50. int i, j;
  51. for (i = 0; i < height; i++) {
  52. for (j = 0; j < width; j++)
  53. dst[j] = ((2 * src[j] + src[j + 1] + 1) *
  54. 683) >> 11;
  55. src += stride;
  56. dst += stride;
  57. }
  58. }
  59. static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
  60. int stride, int width, int height)
  61. {
  62. int i, j;
  63. for (i = 0; i < height; i++) {
  64. for (j = 0; j < width; j++)
  65. dst[j] = ((src[j] + 2 * src[j + 1] + 1) *
  66. 683) >> 11;
  67. src += stride;
  68. dst += stride;
  69. }
  70. }
  71. static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
  72. int stride, int width, int height)
  73. {
  74. int i, j;
  75. for (i = 0; i < height; i++) {
  76. for (j = 0; j < width; j++)
  77. dst[j] = ((2 * src[j] + src[j + stride] + 1) *
  78. 683) >> 11;
  79. src += stride;
  80. dst += stride;
  81. }
  82. }
  83. static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
  84. int stride, int width, int height)
  85. {
  86. int i, j;
  87. for (i = 0; i < height; i++) {
  88. for (j = 0; j < width; j++)
  89. dst[j] = ((4 * src[j] + 3 * src[j + 1] +
  90. 3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
  91. 2731) >> 15;
  92. src += stride;
  93. dst += stride;
  94. }
  95. }
  96. static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
  97. int stride, int width, int height)
  98. {
  99. int i, j;
  100. for (i = 0; i < height; i++) {
  101. for (j = 0; j < width; j++)
  102. dst[j] = ((3 * src[j] + 2 * src[j + 1] +
  103. 4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
  104. 2731) >> 15;
  105. src += stride;
  106. dst += stride;
  107. }
  108. }
  109. static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
  110. int stride, int width, int height)
  111. {
  112. int i, j;
  113. for (i = 0; i < height; i++) {
  114. for (j = 0; j < width; j++)
  115. dst[j] = ((src[j] + 2 * src[j + stride] + 1) *
  116. 683) >> 11;
  117. src += stride;
  118. dst += stride;
  119. }
  120. }
  121. static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
  122. int stride, int width, int height)
  123. {
  124. int i, j;
  125. for (i = 0; i < height; i++) {
  126. for (j = 0; j < width; j++)
  127. dst[j] = ((3 * src[j] + 4 * src[j + 1] +
  128. 2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
  129. 2731) >> 15;
  130. src += stride;
  131. dst += stride;
  132. }
  133. }
  134. static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
  135. int stride, int width, int height)
  136. {
  137. int i, j;
  138. for (i = 0; i < height; i++) {
  139. for (j = 0; j < width; j++)
  140. dst[j] = ((2 * src[j] + 3 * src[j + 1] +
  141. 3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
  142. 2731) >> 15;
  143. src += stride;
  144. dst += stride;
  145. }
  146. }
  147. static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
  148. int stride, int width, int height)
  149. {
  150. switch (width) {
  151. case 2:
  152. avg_pixels2_8_c(dst, src, stride, height);
  153. break;
  154. case 4:
  155. avg_pixels4_8_c(dst, src, stride, height);
  156. break;
  157. case 8:
  158. avg_pixels8_8_c(dst, src, stride, height);
  159. break;
  160. case 16:
  161. avg_pixels16_8_c(dst, src, stride, height);
  162. break;
  163. }
  164. }
  165. static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
  166. int stride, int width, int height)
  167. {
  168. int i, j;
  169. for (i = 0; i < height; i++) {
  170. for (j = 0; j < width; j++)
  171. dst[j] = (dst[j] +
  172. (((2 * src[j] + src[j + 1] + 1) *
  173. 683) >> 11) + 1) >> 1;
  174. src += stride;
  175. dst += stride;
  176. }
  177. }
  178. static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
  179. int stride, int width, int height)
  180. {
  181. int i, j;
  182. for (i = 0; i < height; i++) {
  183. for (j = 0; j < width; j++)
  184. dst[j] = (dst[j] +
  185. (((src[j] + 2 * src[j + 1] + 1) *
  186. 683) >> 11) + 1) >> 1;
  187. src += stride;
  188. dst += stride;
  189. }
  190. }
  191. static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
  192. int stride, int width, int height)
  193. {
  194. int i, j;
  195. for (i = 0; i < height; i++) {
  196. for (j = 0; j < width; j++)
  197. dst[j] = (dst[j] +
  198. (((2 * src[j] + src[j + stride] + 1) *
  199. 683) >> 11) + 1) >> 1;
  200. src += stride;
  201. dst += stride;
  202. }
  203. }
  204. static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
  205. int stride, int width, int height)
  206. {
  207. int i, j;
  208. for (i = 0; i < height; i++) {
  209. for (j = 0; j < width; j++)
  210. dst[j] = (dst[j] +
  211. (((4 * src[j] + 3 * src[j + 1] +
  212. 3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
  213. 2731) >> 15) + 1) >> 1;
  214. src += stride;
  215. dst += stride;
  216. }
  217. }
  218. static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
  219. int stride, int width, int height)
  220. {
  221. int i, j;
  222. for (i = 0; i < height; i++) {
  223. for (j = 0; j < width; j++)
  224. dst[j] = (dst[j] +
  225. (((3 * src[j] + 2 * src[j + 1] +
  226. 4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
  227. 2731) >> 15) + 1) >> 1;
  228. src += stride;
  229. dst += stride;
  230. }
  231. }
  232. static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
  233. int stride, int width, int height)
  234. {
  235. int i, j;
  236. for (i = 0; i < height; i++) {
  237. for (j = 0; j < width; j++)
  238. dst[j] = (dst[j] +
  239. (((src[j] + 2 * src[j + stride] + 1) *
  240. 683) >> 11) + 1) >> 1;
  241. src += stride;
  242. dst += stride;
  243. }
  244. }
  245. static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
  246. int stride, int width, int height)
  247. {
  248. int i, j;
  249. for (i = 0; i < height; i++) {
  250. for (j = 0; j < width; j++)
  251. dst[j] = (dst[j] +
  252. (((3 * src[j] + 4 * src[j + 1] +
  253. 2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
  254. 2731) >> 15) + 1) >> 1;
  255. src += stride;
  256. dst += stride;
  257. }
  258. }
  259. static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
  260. int stride, int width, int height)
  261. {
  262. int i, j;
  263. for (i = 0; i < height; i++) {
  264. for (j = 0; j < width; j++)
  265. dst[j] = (dst[j] +
  266. (((2 * src[j] + 3 * src[j + 1] +
  267. 3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
  268. 2731) >> 15) + 1) >> 1;
  269. src += stride;
  270. dst += stride;
  271. }
  272. }
  273. av_cold void ff_tpeldsp_init(TpelDSPContext *c)
  274. {
  275. c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
  276. c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
  277. c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
  278. c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
  279. c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
  280. c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
  281. c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
  282. c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
  283. c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
  284. c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
  285. c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
  286. c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
  287. c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
  288. c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
  289. c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
  290. c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
  291. c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
  292. c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
  293. }