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.

550 lines
24KB

  1. /*
  2. * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
  3. * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * Libav is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "libavutil/common.h"
  22. #include "bit_depth_template.c"
  23. #include "hpel_template.c"
  24. static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
  25. {
  26. int i;
  27. for(i=0; i<h; i++)
  28. {
  29. AV_WN2P(dst , AV_RN2P(src ));
  30. dst+=dstStride;
  31. src+=srcStride;
  32. }
  33. }
  34. static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
  35. {
  36. int i;
  37. for(i=0; i<h; i++)
  38. {
  39. AV_WN4P(dst , AV_RN4P(src ));
  40. dst+=dstStride;
  41. src+=srcStride;
  42. }
  43. }
  44. static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
  45. {
  46. int i;
  47. for(i=0; i<h; i++)
  48. {
  49. AV_WN4P(dst , AV_RN4P(src ));
  50. AV_WN4P(dst+4*sizeof(pixel), AV_RN4P(src+4*sizeof(pixel)));
  51. dst+=dstStride;
  52. src+=srcStride;
  53. }
  54. }
  55. static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
  56. {
  57. int i;
  58. for(i=0; i<h; i++)
  59. {
  60. AV_WN4P(dst , AV_RN4P(src ));
  61. AV_WN4P(dst+ 4*sizeof(pixel), AV_RN4P(src+ 4*sizeof(pixel)));
  62. AV_WN4P(dst+ 8*sizeof(pixel), AV_RN4P(src+ 8*sizeof(pixel)));
  63. AV_WN4P(dst+12*sizeof(pixel), AV_RN4P(src+12*sizeof(pixel)));
  64. dst+=dstStride;
  65. src+=srcStride;
  66. }
  67. }
  68. #define H264_LOWPASS(OPNAME, OP, OP2) \
  69. static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
  70. const int h=2;\
  71. INIT_CLIP\
  72. int i;\
  73. pixel *dst = (pixel*)_dst;\
  74. pixel *src = (pixel*)_src;\
  75. dstStride /= sizeof(pixel);\
  76. srcStride /= sizeof(pixel);\
  77. for(i=0; i<h; i++)\
  78. {\
  79. OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
  80. OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
  81. dst+=dstStride;\
  82. src+=srcStride;\
  83. }\
  84. }\
  85. \
  86. static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
  87. const int w=2;\
  88. INIT_CLIP\
  89. int i;\
  90. pixel *dst = (pixel*)_dst;\
  91. pixel *src = (pixel*)_src;\
  92. dstStride /= sizeof(pixel);\
  93. srcStride /= sizeof(pixel);\
  94. for(i=0; i<w; i++)\
  95. {\
  96. const int srcB= src[-2*srcStride];\
  97. const int srcA= src[-1*srcStride];\
  98. const int src0= src[0 *srcStride];\
  99. const int src1= src[1 *srcStride];\
  100. const int src2= src[2 *srcStride];\
  101. const int src3= src[3 *srcStride];\
  102. const int src4= src[4 *srcStride];\
  103. OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
  104. OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
  105. dst++;\
  106. src++;\
  107. }\
  108. }\
  109. \
  110. static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\
  111. const int h=2;\
  112. const int w=2;\
  113. const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
  114. INIT_CLIP\
  115. int i;\
  116. pixel *dst = (pixel*)_dst;\
  117. pixel *src = (pixel*)_src;\
  118. dstStride /= sizeof(pixel);\
  119. srcStride /= sizeof(pixel);\
  120. src -= 2*srcStride;\
  121. for(i=0; i<h+5; i++)\
  122. {\
  123. tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
  124. tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
  125. tmp+=tmpStride;\
  126. src+=srcStride;\
  127. }\
  128. tmp -= tmpStride*(h+5-2);\
  129. for(i=0; i<w; i++)\
  130. {\
  131. const int tmpB= tmp[-2*tmpStride] - pad;\
  132. const int tmpA= tmp[-1*tmpStride] - pad;\
  133. const int tmp0= tmp[0 *tmpStride] - pad;\
  134. const int tmp1= tmp[1 *tmpStride] - pad;\
  135. const int tmp2= tmp[2 *tmpStride] - pad;\
  136. const int tmp3= tmp[3 *tmpStride] - pad;\
  137. const int tmp4= tmp[4 *tmpStride] - pad;\
  138. OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
  139. OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
  140. dst++;\
  141. tmp++;\
  142. }\
  143. }\
  144. static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
  145. const int h=4;\
  146. INIT_CLIP\
  147. int i;\
  148. pixel *dst = (pixel*)_dst;\
  149. pixel *src = (pixel*)_src;\
  150. dstStride /= sizeof(pixel);\
  151. srcStride /= sizeof(pixel);\
  152. for(i=0; i<h; i++)\
  153. {\
  154. OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
  155. OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
  156. OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
  157. OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
  158. dst+=dstStride;\
  159. src+=srcStride;\
  160. }\
  161. }\
  162. \
  163. static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
  164. const int w=4;\
  165. INIT_CLIP\
  166. int i;\
  167. pixel *dst = (pixel*)_dst;\
  168. pixel *src = (pixel*)_src;\
  169. dstStride /= sizeof(pixel);\
  170. srcStride /= sizeof(pixel);\
  171. for(i=0; i<w; i++)\
  172. {\
  173. const int srcB= src[-2*srcStride];\
  174. const int srcA= src[-1*srcStride];\
  175. const int src0= src[0 *srcStride];\
  176. const int src1= src[1 *srcStride];\
  177. const int src2= src[2 *srcStride];\
  178. const int src3= src[3 *srcStride];\
  179. const int src4= src[4 *srcStride];\
  180. const int src5= src[5 *srcStride];\
  181. const int src6= src[6 *srcStride];\
  182. OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
  183. OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
  184. OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
  185. OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
  186. dst++;\
  187. src++;\
  188. }\
  189. }\
  190. \
  191. static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\
  192. const int h=4;\
  193. const int w=4;\
  194. const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
  195. INIT_CLIP\
  196. int i;\
  197. pixel *dst = (pixel*)_dst;\
  198. pixel *src = (pixel*)_src;\
  199. dstStride /= sizeof(pixel);\
  200. srcStride /= sizeof(pixel);\
  201. src -= 2*srcStride;\
  202. for(i=0; i<h+5; i++)\
  203. {\
  204. tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
  205. tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
  206. tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]) + pad;\
  207. tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]) + pad;\
  208. tmp+=tmpStride;\
  209. src+=srcStride;\
  210. }\
  211. tmp -= tmpStride*(h+5-2);\
  212. for(i=0; i<w; i++)\
  213. {\
  214. const int tmpB= tmp[-2*tmpStride] - pad;\
  215. const int tmpA= tmp[-1*tmpStride] - pad;\
  216. const int tmp0= tmp[0 *tmpStride] - pad;\
  217. const int tmp1= tmp[1 *tmpStride] - pad;\
  218. const int tmp2= tmp[2 *tmpStride] - pad;\
  219. const int tmp3= tmp[3 *tmpStride] - pad;\
  220. const int tmp4= tmp[4 *tmpStride] - pad;\
  221. const int tmp5= tmp[5 *tmpStride] - pad;\
  222. const int tmp6= tmp[6 *tmpStride] - pad;\
  223. OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
  224. OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
  225. OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
  226. OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
  227. dst++;\
  228. tmp++;\
  229. }\
  230. }\
  231. \
  232. static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
  233. const int h=8;\
  234. INIT_CLIP\
  235. int i;\
  236. pixel *dst = (pixel*)_dst;\
  237. pixel *src = (pixel*)_src;\
  238. dstStride /= sizeof(pixel);\
  239. srcStride /= sizeof(pixel);\
  240. for(i=0; i<h; i++)\
  241. {\
  242. OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
  243. OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
  244. OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
  245. OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
  246. OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
  247. OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
  248. OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
  249. OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
  250. dst+=dstStride;\
  251. src+=srcStride;\
  252. }\
  253. }\
  254. \
  255. static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
  256. const int w=8;\
  257. INIT_CLIP\
  258. int i;\
  259. pixel *dst = (pixel*)_dst;\
  260. pixel *src = (pixel*)_src;\
  261. dstStride /= sizeof(pixel);\
  262. srcStride /= sizeof(pixel);\
  263. for(i=0; i<w; i++)\
  264. {\
  265. const int srcB= src[-2*srcStride];\
  266. const int srcA= src[-1*srcStride];\
  267. const int src0= src[0 *srcStride];\
  268. const int src1= src[1 *srcStride];\
  269. const int src2= src[2 *srcStride];\
  270. const int src3= src[3 *srcStride];\
  271. const int src4= src[4 *srcStride];\
  272. const int src5= src[5 *srcStride];\
  273. const int src6= src[6 *srcStride];\
  274. const int src7= src[7 *srcStride];\
  275. const int src8= src[8 *srcStride];\
  276. const int src9= src[9 *srcStride];\
  277. const int src10=src[10*srcStride];\
  278. OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
  279. OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
  280. OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
  281. OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
  282. OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
  283. OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
  284. OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
  285. OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
  286. dst++;\
  287. src++;\
  288. }\
  289. }\
  290. \
  291. static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\
  292. const int h=8;\
  293. const int w=8;\
  294. const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
  295. INIT_CLIP\
  296. int i;\
  297. pixel *dst = (pixel*)_dst;\
  298. pixel *src = (pixel*)_src;\
  299. dstStride /= sizeof(pixel);\
  300. srcStride /= sizeof(pixel);\
  301. src -= 2*srcStride;\
  302. for(i=0; i<h+5; i++)\
  303. {\
  304. tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]) + pad;\
  305. tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]) + pad;\
  306. tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]) + pad;\
  307. tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]) + pad;\
  308. tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]) + pad;\
  309. tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]) + pad;\
  310. tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]) + pad;\
  311. tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]) + pad;\
  312. tmp+=tmpStride;\
  313. src+=srcStride;\
  314. }\
  315. tmp -= tmpStride*(h+5-2);\
  316. for(i=0; i<w; i++)\
  317. {\
  318. const int tmpB= tmp[-2*tmpStride] - pad;\
  319. const int tmpA= tmp[-1*tmpStride] - pad;\
  320. const int tmp0= tmp[0 *tmpStride] - pad;\
  321. const int tmp1= tmp[1 *tmpStride] - pad;\
  322. const int tmp2= tmp[2 *tmpStride] - pad;\
  323. const int tmp3= tmp[3 *tmpStride] - pad;\
  324. const int tmp4= tmp[4 *tmpStride] - pad;\
  325. const int tmp5= tmp[5 *tmpStride] - pad;\
  326. const int tmp6= tmp[6 *tmpStride] - pad;\
  327. const int tmp7= tmp[7 *tmpStride] - pad;\
  328. const int tmp8= tmp[8 *tmpStride] - pad;\
  329. const int tmp9= tmp[9 *tmpStride] - pad;\
  330. const int tmp10=tmp[10*tmpStride] - pad;\
  331. OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
  332. OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
  333. OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
  334. OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
  335. OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
  336. OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
  337. OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
  338. OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
  339. dst++;\
  340. tmp++;\
  341. }\
  342. }\
  343. \
  344. static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  345. FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
  346. FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
  347. src += 8*srcStride;\
  348. dst += 8*dstStride;\
  349. FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
  350. FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
  351. }\
  352. \
  353. static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  354. FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
  355. FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
  356. src += 8*srcStride;\
  357. dst += 8*dstStride;\
  358. FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
  359. FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
  360. }\
  361. \
  362. static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  363. FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
  364. FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
  365. src += 8*srcStride;\
  366. dst += 8*dstStride;\
  367. FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
  368. FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
  369. }\
  370. #define H264_MC(OPNAME, SIZE) \
  371. static av_unused void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  372. {\
  373. FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
  374. }\
  375. \
  376. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  377. {\
  378. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  379. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
  380. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
  381. }\
  382. \
  383. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  384. {\
  385. FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
  386. }\
  387. \
  388. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  389. {\
  390. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  391. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
  392. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
  393. }\
  394. \
  395. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  396. {\
  397. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  398. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  399. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  400. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  401. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  402. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  403. }\
  404. \
  405. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  406. {\
  407. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  408. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  409. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  410. FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
  411. }\
  412. \
  413. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  414. {\
  415. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  416. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  417. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  418. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  419. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  420. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  421. }\
  422. \
  423. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  424. {\
  425. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  426. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  427. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  428. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  429. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
  430. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  431. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  432. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  433. }\
  434. \
  435. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  436. {\
  437. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  438. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  439. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  440. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  441. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
  442. FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
  443. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  444. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  445. }\
  446. \
  447. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  448. {\
  449. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  450. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  451. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  452. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  453. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
  454. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  455. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  456. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  457. }\
  458. \
  459. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  460. {\
  461. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  462. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  463. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  464. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  465. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
  466. FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
  467. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  468. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  469. }\
  470. \
  471. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  472. {\
  473. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  474. FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
  475. }\
  476. \
  477. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  478. {\
  479. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  480. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  481. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  482. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
  483. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  484. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  485. }\
  486. \
  487. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  488. {\
  489. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  490. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  491. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  492. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
  493. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  494. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  495. }\
  496. \
  497. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  498. {\
  499. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  500. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  501. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  502. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  503. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  504. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  505. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  506. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  507. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  508. }\
  509. \
  510. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  511. {\
  512. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  513. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  514. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  515. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  516. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  517. FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
  518. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  519. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  520. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  521. }\
  522. #define op_avg(a, b) a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
  523. //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
  524. #define op_put(a, b) a = CLIP(((b) + 16)>>5)
  525. #define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
  526. #define op2_put(a, b) a = CLIP(((b) + 512)>>10)
  527. H264_LOWPASS(put_ , op_put, op2_put)
  528. H264_LOWPASS(avg_ , op_avg, op2_avg)
  529. H264_MC(put_, 2)
  530. H264_MC(put_, 4)
  531. H264_MC(put_, 8)
  532. H264_MC(put_, 16)
  533. H264_MC(avg_, 4)
  534. H264_MC(avg_, 8)
  535. H264_MC(avg_, 16)
  536. #undef op_avg
  537. #undef op_put
  538. #undef op2_avg
  539. #undef op2_put