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.

551 lines
25KB

  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, int stride){\
  372. FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
  373. }\
  374. \
  375. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, int stride){\
  376. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  377. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
  378. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
  379. }\
  380. \
  381. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, int stride){\
  382. FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
  383. }\
  384. \
  385. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, int stride){\
  386. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  387. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
  388. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
  389. }\
  390. \
  391. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, int stride){\
  392. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  393. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  394. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  395. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  396. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  397. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  398. }\
  399. \
  400. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, int stride){\
  401. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  402. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  403. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  404. FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
  405. }\
  406. \
  407. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, int stride){\
  408. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  409. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  410. uint8_t half[SIZE*SIZE*sizeof(pixel)];\
  411. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  412. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  413. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  414. }\
  415. \
  416. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, int stride){\
  417. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  418. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  419. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  420. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  421. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
  422. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  423. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  424. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  425. }\
  426. \
  427. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, int stride){\
  428. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  429. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  430. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  431. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  432. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
  433. FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
  434. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  435. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  436. }\
  437. \
  438. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, int stride){\
  439. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  440. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  441. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  442. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  443. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
  444. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  445. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  446. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  447. }\
  448. \
  449. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, int stride){\
  450. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  451. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  452. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  453. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  454. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
  455. FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
  456. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  457. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  458. }\
  459. \
  460. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, int stride){\
  461. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  462. FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
  463. }\
  464. \
  465. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, int stride){\
  466. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  467. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  468. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  469. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
  470. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  471. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  472. }\
  473. \
  474. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, int stride){\
  475. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  476. uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
  477. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  478. FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
  479. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  480. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  481. }\
  482. \
  483. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, int stride){\
  484. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  485. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  486. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  487. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  488. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  489. FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
  490. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  491. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  492. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  493. }\
  494. \
  495. static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, int stride){\
  496. uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
  497. uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
  498. int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
  499. uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
  500. uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
  501. FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
  502. FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
  503. FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
  504. FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
  505. }\
  506. #define op_avg(a, b) a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
  507. //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
  508. #define op_put(a, b) a = CLIP(((b) + 16)>>5)
  509. #define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
  510. #define op2_put(a, b) a = CLIP(((b) + 512)>>10)
  511. H264_LOWPASS(put_ , op_put, op2_put)
  512. H264_LOWPASS(avg_ , op_avg, op2_avg)
  513. H264_MC(put_, 2)
  514. H264_MC(put_, 4)
  515. H264_MC(put_, 8)
  516. H264_MC(put_, 16)
  517. H264_MC(avg_, 4)
  518. H264_MC(avg_, 8)
  519. H264_MC(avg_, 16)
  520. #undef op_avg
  521. #undef op_put
  522. #undef op2_avg
  523. #undef op2_put
  524. #if BIT_DEPTH == 8
  525. # define put_h264_qpel8_mc00_8_c ff_put_pixels8x8_8_c
  526. # define avg_h264_qpel8_mc00_8_c ff_avg_pixels8x8_8_c
  527. # define put_h264_qpel16_mc00_8_c ff_put_pixels16x16_8_c
  528. # define avg_h264_qpel16_mc00_8_c ff_avg_pixels16x16_8_c
  529. #elif BIT_DEPTH == 9
  530. # define put_h264_qpel8_mc00_9_c ff_put_pixels8x8_9_c
  531. # define avg_h264_qpel8_mc00_9_c ff_avg_pixels8x8_9_c
  532. # define put_h264_qpel16_mc00_9_c ff_put_pixels16x16_9_c
  533. # define avg_h264_qpel16_mc00_9_c ff_avg_pixels16x16_9_c
  534. #elif BIT_DEPTH == 10
  535. # define put_h264_qpel8_mc00_10_c ff_put_pixels8x8_10_c
  536. # define avg_h264_qpel8_mc00_10_c ff_avg_pixels8x8_10_c
  537. # define put_h264_qpel16_mc00_10_c ff_put_pixels16x16_10_c
  538. # define avg_h264_qpel16_mc00_10_c ff_avg_pixels16x16_10_c
  539. #endif