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.

538 lines
20KB

  1. /*
  2. * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
  3. * Copyright (c) 2003 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. /**
  22. * @file
  23. * H.264 / AVC / MPEG4 part10 prediction functions.
  24. * @author Michael Niedermayer <michaelni@gmx.at>
  25. */
  26. #include "h264pred.h"
  27. #define BIT_DEPTH 8
  28. #include "h264pred_template.c"
  29. #undef BIT_DEPTH
  30. #define BIT_DEPTH 9
  31. #include "h264pred_template.c"
  32. #undef BIT_DEPTH
  33. #define BIT_DEPTH 10
  34. #include "h264pred_template.c"
  35. #undef BIT_DEPTH
  36. static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
  37. const unsigned lt = src[-1-1*stride];
  38. LOAD_TOP_EDGE
  39. LOAD_TOP_RIGHT_EDGE
  40. uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2,
  41. (t0 + 2*t1 + t2 + 2) >> 2,
  42. (t1 + 2*t2 + t3 + 2) >> 2,
  43. (t2 + 2*t3 + t4 + 2) >> 2);
  44. AV_WN32A(src+0*stride, v);
  45. AV_WN32A(src+1*stride, v);
  46. AV_WN32A(src+2*stride, v);
  47. AV_WN32A(src+3*stride, v);
  48. }
  49. static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
  50. const unsigned lt = src[-1-1*stride];
  51. LOAD_LEFT_EDGE
  52. AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101);
  53. AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101);
  54. AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101);
  55. AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101);
  56. }
  57. static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright, int stride){
  58. LOAD_TOP_EDGE
  59. LOAD_LEFT_EDGE
  60. src[0+0*stride]=(l1 + t1)>>1;
  61. src[1+0*stride]=
  62. src[0+1*stride]=(l2 + t2)>>1;
  63. src[2+0*stride]=
  64. src[1+1*stride]=
  65. src[0+2*stride]=
  66. src[3+0*stride]=
  67. src[2+1*stride]=
  68. src[1+2*stride]=
  69. src[0+3*stride]=
  70. src[3+1*stride]=
  71. src[2+2*stride]=
  72. src[1+3*stride]=
  73. src[3+2*stride]=
  74. src[2+3*stride]=
  75. src[3+3*stride]=(l3 + t3)>>1;
  76. }
  77. static void pred4x4_down_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
  78. LOAD_TOP_EDGE
  79. LOAD_TOP_RIGHT_EDGE
  80. LOAD_LEFT_EDGE
  81. LOAD_DOWN_LEFT_EDGE
  82. src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
  83. src[1+0*stride]=
  84. src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
  85. src[2+0*stride]=
  86. src[1+1*stride]=
  87. src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + l4 + 2*l3 + 2)>>3;
  88. src[3+0*stride]=
  89. src[2+1*stride]=
  90. src[1+2*stride]=
  91. src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3 + l5 + 2*l4 + 2)>>3;
  92. src[3+1*stride]=
  93. src[2+2*stride]=
  94. src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l4 + l6 + 2*l5 + 2)>>3;
  95. src[3+2*stride]=
  96. src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l5 + l7 + 2*l6 + 2)>>3;
  97. src[3+3*stride]=(t6 + t7 + 1 + l6 + l7 + 1)>>2;
  98. }
  99. static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
  100. LOAD_TOP_EDGE
  101. LOAD_TOP_RIGHT_EDGE
  102. LOAD_LEFT_EDGE
  103. src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
  104. src[1+0*stride]=
  105. src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
  106. src[2+0*stride]=
  107. src[1+1*stride]=
  108. src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + 3*l3 + 2)>>3;
  109. src[3+0*stride]=
  110. src[2+1*stride]=
  111. src[1+2*stride]=
  112. src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3*4 + 2)>>3;
  113. src[3+1*stride]=
  114. src[2+2*stride]=
  115. src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l3*4 + 2)>>3;
  116. src[3+2*stride]=
  117. src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l3*4 + 2)>>3;
  118. src[3+3*stride]=(t6 + t7 + 1 + 2*l3 + 1)>>2;
  119. }
  120. static void pred4x4_vertical_left_rv40(uint8_t *src, const uint8_t *topright, int stride,
  121. const int l0, const int l1, const int l2, const int l3, const int l4){
  122. LOAD_TOP_EDGE
  123. LOAD_TOP_RIGHT_EDGE
  124. src[0+0*stride]=(2*t0 + 2*t1 + l1 + 2*l2 + l3 + 4)>>3;
  125. src[1+0*stride]=
  126. src[0+2*stride]=(t1 + t2 + 1)>>1;
  127. src[2+0*stride]=
  128. src[1+2*stride]=(t2 + t3 + 1)>>1;
  129. src[3+0*stride]=
  130. src[2+2*stride]=(t3 + t4+ 1)>>1;
  131. src[3+2*stride]=(t4 + t5+ 1)>>1;
  132. src[0+1*stride]=(t0 + 2*t1 + t2 + l2 + 2*l3 + l4 + 4)>>3;
  133. src[1+1*stride]=
  134. src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
  135. src[2+1*stride]=
  136. src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
  137. src[3+1*stride]=
  138. src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
  139. src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
  140. }
  141. static void pred4x4_vertical_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
  142. LOAD_LEFT_EDGE
  143. LOAD_DOWN_LEFT_EDGE
  144. pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4);
  145. }
  146. static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
  147. LOAD_LEFT_EDGE
  148. pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3);
  149. }
  150. static void pred4x4_vertical_left_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
  151. LOAD_TOP_EDGE
  152. LOAD_TOP_RIGHT_EDGE
  153. src[0+0*stride]=(t0 + t1 + 1)>>1;
  154. src[1+0*stride]=
  155. src[0+2*stride]=(t1 + t2 + 1)>>1;
  156. src[2+0*stride]=
  157. src[1+2*stride]=(t2 + t3 + 1)>>1;
  158. src[3+0*stride]=
  159. src[2+2*stride]=(t3 + t4 + 1)>>1;
  160. src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
  161. src[1+1*stride]=
  162. src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
  163. src[2+1*stride]=
  164. src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
  165. src[3+1*stride]=
  166. src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
  167. src[3+2*stride]=(t4 + 2*t5 + t6 + 2)>>2;
  168. src[3+3*stride]=(t5 + 2*t6 + t7 + 2)>>2;
  169. }
  170. static void pred4x4_horizontal_up_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
  171. LOAD_LEFT_EDGE
  172. LOAD_DOWN_LEFT_EDGE
  173. LOAD_TOP_EDGE
  174. LOAD_TOP_RIGHT_EDGE
  175. src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
  176. src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
  177. src[2+0*stride]=
  178. src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
  179. src[3+0*stride]=
  180. src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
  181. src[2+1*stride]=
  182. src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
  183. src[3+1*stride]=
  184. src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
  185. src[3+2*stride]=
  186. src[1+3*stride]=(l3 + 2*l4 + l5 + 2)>>2;
  187. src[0+3*stride]=
  188. src[2+2*stride]=(t6 + t7 + l3 + l4 + 2)>>2;
  189. src[2+3*stride]=(l4 + l5 + 1)>>1;
  190. src[3+3*stride]=(l4 + 2*l5 + l6 + 2)>>2;
  191. }
  192. static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
  193. LOAD_LEFT_EDGE
  194. LOAD_TOP_EDGE
  195. LOAD_TOP_RIGHT_EDGE
  196. src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
  197. src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
  198. src[2+0*stride]=
  199. src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
  200. src[3+0*stride]=
  201. src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
  202. src[2+1*stride]=
  203. src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
  204. src[3+1*stride]=
  205. src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
  206. src[3+2*stride]=
  207. src[1+3*stride]=l3;
  208. src[0+3*stride]=
  209. src[2+2*stride]=(t6 + t7 + 2*l3 + 2)>>2;
  210. src[2+3*stride]=
  211. src[3+3*stride]=l3;
  212. }
  213. static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
  214. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
  215. uint8_t *top = src-stride;
  216. int y;
  217. for (y = 0; y < 4; y++) {
  218. uint8_t *cm_in = cm + src[-1];
  219. src[0] = cm_in[top[0]];
  220. src[1] = cm_in[top[1]];
  221. src[2] = cm_in[top[2]];
  222. src[3] = cm_in[top[3]];
  223. src += stride;
  224. }
  225. }
  226. static void pred16x16_plane_svq3_c(uint8_t *src, int stride){
  227. pred16x16_plane_compat_8_c(src, stride, 1, 0);
  228. }
  229. static void pred16x16_plane_rv40_c(uint8_t *src, int stride){
  230. pred16x16_plane_compat_8_c(src, stride, 0, 1);
  231. }
  232. static void pred16x16_tm_vp8_c(uint8_t *src, int stride){
  233. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
  234. uint8_t *top = src-stride;
  235. int y;
  236. for (y = 0; y < 16; y++) {
  237. uint8_t *cm_in = cm + src[-1];
  238. src[0] = cm_in[top[0]];
  239. src[1] = cm_in[top[1]];
  240. src[2] = cm_in[top[2]];
  241. src[3] = cm_in[top[3]];
  242. src[4] = cm_in[top[4]];
  243. src[5] = cm_in[top[5]];
  244. src[6] = cm_in[top[6]];
  245. src[7] = cm_in[top[7]];
  246. src[8] = cm_in[top[8]];
  247. src[9] = cm_in[top[9]];
  248. src[10] = cm_in[top[10]];
  249. src[11] = cm_in[top[11]];
  250. src[12] = cm_in[top[12]];
  251. src[13] = cm_in[top[13]];
  252. src[14] = cm_in[top[14]];
  253. src[15] = cm_in[top[15]];
  254. src += stride;
  255. }
  256. }
  257. static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){
  258. int i;
  259. unsigned dc0;
  260. dc0=0;
  261. for(i=0;i<8; i++)
  262. dc0+= src[-1+i*stride];
  263. dc0= 0x01010101*((dc0 + 4)>>3);
  264. for(i=0; i<8; i++){
  265. ((uint32_t*)(src+i*stride))[0]=
  266. ((uint32_t*)(src+i*stride))[1]= dc0;
  267. }
  268. }
  269. static void pred8x8_top_dc_rv40_c(uint8_t *src, int stride){
  270. int i;
  271. unsigned dc0;
  272. dc0=0;
  273. for(i=0;i<8; i++)
  274. dc0+= src[i-stride];
  275. dc0= 0x01010101*((dc0 + 4)>>3);
  276. for(i=0; i<8; i++){
  277. ((uint32_t*)(src+i*stride))[0]=
  278. ((uint32_t*)(src+i*stride))[1]= dc0;
  279. }
  280. }
  281. static void pred8x8_dc_rv40_c(uint8_t *src, int stride){
  282. int i;
  283. unsigned dc0 = 0;
  284. for(i=0;i<4; i++){
  285. dc0+= src[-1+i*stride] + src[i-stride];
  286. dc0+= src[4+i-stride];
  287. dc0+= src[-1+(i+4)*stride];
  288. }
  289. dc0= 0x01010101*((dc0 + 8)>>4);
  290. for(i=0; i<4; i++){
  291. ((uint32_t*)(src+i*stride))[0]= dc0;
  292. ((uint32_t*)(src+i*stride))[1]= dc0;
  293. }
  294. for(i=4; i<8; i++){
  295. ((uint32_t*)(src+i*stride))[0]= dc0;
  296. ((uint32_t*)(src+i*stride))[1]= dc0;
  297. }
  298. }
  299. static void pred8x8_tm_vp8_c(uint8_t *src, int stride){
  300. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
  301. uint8_t *top = src-stride;
  302. int y;
  303. for (y = 0; y < 8; y++) {
  304. uint8_t *cm_in = cm + src[-1];
  305. src[0] = cm_in[top[0]];
  306. src[1] = cm_in[top[1]];
  307. src[2] = cm_in[top[2]];
  308. src[3] = cm_in[top[3]];
  309. src[4] = cm_in[top[4]];
  310. src[5] = cm_in[top[5]];
  311. src[6] = cm_in[top[6]];
  312. src[7] = cm_in[top[7]];
  313. src += stride;
  314. }
  315. }
  316. /**
  317. * Set the intra prediction function pointers.
  318. */
  319. void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc){
  320. // MpegEncContext * const s = &h->s;
  321. #undef FUNC
  322. #undef FUNCC
  323. #define FUNC(a, depth) a ## _ ## depth
  324. #define FUNCC(a, depth) a ## _ ## depth ## _c
  325. #define FUNCD(a) a ## _c
  326. #define H264_PRED(depth) \
  327. if(codec_id != CODEC_ID_RV40){\
  328. if(codec_id == CODEC_ID_VP8) {\
  329. h->pred4x4[VERT_PRED ]= FUNCD(pred4x4_vertical_vp8);\
  330. h->pred4x4[HOR_PRED ]= FUNCD(pred4x4_horizontal_vp8);\
  331. } else {\
  332. h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
  333. h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
  334. }\
  335. h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\
  336. if(codec_id == CODEC_ID_SVQ3)\
  337. h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_svq3);\
  338. else\
  339. h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left , depth);\
  340. h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\
  341. h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\
  342. h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\
  343. if (codec_id == CODEC_ID_VP8) {\
  344. h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_vp8);\
  345. } else\
  346. h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left , depth);\
  347. h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up , depth);\
  348. if(codec_id != CODEC_ID_VP8) {\
  349. h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\
  350. h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\
  351. h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\
  352. } else {\
  353. h->pred4x4[TM_VP8_PRED ]= FUNCD(pred4x4_tm_vp8);\
  354. h->pred4x4[DC_127_PRED ]= FUNCC(pred4x4_127_dc , depth);\
  355. h->pred4x4[DC_129_PRED ]= FUNCC(pred4x4_129_dc , depth);\
  356. h->pred4x4[VERT_VP8_PRED ]= FUNCC(pred4x4_vertical , depth);\
  357. h->pred4x4[HOR_VP8_PRED ]= FUNCC(pred4x4_horizontal , depth);\
  358. }\
  359. }else{\
  360. h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
  361. h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
  362. h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\
  363. h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_rv40);\
  364. h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\
  365. h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\
  366. h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\
  367. h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_rv40);\
  368. h->pred4x4[HOR_UP_PRED ]= FUNCD(pred4x4_horizontal_up_rv40);\
  369. h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\
  370. h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\
  371. h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\
  372. h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_down_left_rv40_nodown);\
  373. h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCD(pred4x4_horizontal_up_rv40_nodown);\
  374. h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_vertical_left_rv40_nodown);\
  375. }\
  376. \
  377. h->pred8x8l[VERT_PRED ]= FUNCC(pred8x8l_vertical , depth);\
  378. h->pred8x8l[HOR_PRED ]= FUNCC(pred8x8l_horizontal , depth);\
  379. h->pred8x8l[DC_PRED ]= FUNCC(pred8x8l_dc , depth);\
  380. h->pred8x8l[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred8x8l_down_left , depth);\
  381. h->pred8x8l[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred8x8l_down_right , depth);\
  382. h->pred8x8l[VERT_RIGHT_PRED ]= FUNCC(pred8x8l_vertical_right , depth);\
  383. h->pred8x8l[HOR_DOWN_PRED ]= FUNCC(pred8x8l_horizontal_down , depth);\
  384. h->pred8x8l[VERT_LEFT_PRED ]= FUNCC(pred8x8l_vertical_left , depth);\
  385. h->pred8x8l[HOR_UP_PRED ]= FUNCC(pred8x8l_horizontal_up , depth);\
  386. h->pred8x8l[LEFT_DC_PRED ]= FUNCC(pred8x8l_left_dc , depth);\
  387. h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\
  388. h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\
  389. \
  390. if (chroma_format_idc == 1) {\
  391. h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\
  392. h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\
  393. } else {\
  394. h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x16_vertical , depth);\
  395. h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\
  396. }\
  397. if (codec_id != CODEC_ID_VP8) {\
  398. if (chroma_format_idc == 1) {\
  399. h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\
  400. } else {\
  401. h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane , depth);\
  402. }\
  403. } else\
  404. h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
  405. if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\
  406. if (chroma_format_idc == 1) {\
  407. h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
  408. h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
  409. h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\
  410. h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\
  411. h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\
  412. h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
  413. h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
  414. } else {\
  415. h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x16_dc , depth);\
  416. h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x16_left_dc , depth);\
  417. h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x16_top_dc , depth);\
  418. h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l0t, depth);\
  419. h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0lt, depth);\
  420. h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l00, depth);\
  421. h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0l0, depth);\
  422. }\
  423. }else{\
  424. h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\
  425. h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\
  426. h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\
  427. if (codec_id == CODEC_ID_VP8) {\
  428. h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc , depth);\
  429. h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\
  430. }\
  431. }\
  432. if (chroma_format_idc == 1) {\
  433. h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\
  434. } else {\
  435. h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\
  436. }\
  437. \
  438. h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\
  439. h->pred16x16[VERT_PRED8x8 ]= FUNCC(pred16x16_vertical , depth);\
  440. h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\
  441. switch(codec_id){\
  442. case CODEC_ID_SVQ3:\
  443. h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_svq3);\
  444. break;\
  445. case CODEC_ID_RV40:\
  446. h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_rv40);\
  447. break;\
  448. case CODEC_ID_VP8:\
  449. h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_tm_vp8);\
  450. h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\
  451. h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc , depth);\
  452. break;\
  453. default:\
  454. h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane , depth);\
  455. break;\
  456. }\
  457. h->pred16x16[LEFT_DC_PRED8x8]= FUNCC(pred16x16_left_dc , depth);\
  458. h->pred16x16[TOP_DC_PRED8x8 ]= FUNCC(pred16x16_top_dc , depth);\
  459. h->pred16x16[DC_128_PRED8x8 ]= FUNCC(pred16x16_128_dc , depth);\
  460. \
  461. /* special lossless h/v prediction for h264 */ \
  462. h->pred4x4_add [VERT_PRED ]= FUNCC(pred4x4_vertical_add , depth);\
  463. h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\
  464. h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\
  465. h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\
  466. if (chroma_format_idc == 1) {\
  467. h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\
  468. h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\
  469. } else {\
  470. h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x16_vertical_add , depth);\
  471. h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x16_horizontal_add , depth);\
  472. }\
  473. h->pred16x16_add[VERT_PRED8x8]= FUNCC(pred16x16_vertical_add , depth);\
  474. h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add , depth);\
  475. switch (bit_depth) {
  476. case 9:
  477. H264_PRED(9)
  478. break;
  479. case 10:
  480. H264_PRED(10)
  481. break;
  482. default:
  483. H264_PRED(8)
  484. break;
  485. }
  486. if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
  487. if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
  488. }