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.

667 lines
21KB

  1. /*
  2. * VC-1 and WMV3 decoder - DSP functions
  3. * Copyright (c) 2006 Konstantin Shishkov
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg 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. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file libavcodec/vc1dsp.c
  23. * VC-1 and WMV3 decoder
  24. *
  25. */
  26. #include "dsputil.h"
  27. /** Apply overlap transform to horizontal edge
  28. */
  29. static void vc1_v_overlap_c(uint8_t* src, int stride)
  30. {
  31. int i;
  32. int a, b, c, d;
  33. int d1, d2;
  34. int rnd = 1;
  35. for(i = 0; i < 8; i++) {
  36. a = src[-2*stride];
  37. b = src[-stride];
  38. c = src[0];
  39. d = src[stride];
  40. d1 = (a - d + 3 + rnd) >> 3;
  41. d2 = (a - d + b - c + 4 - rnd) >> 3;
  42. src[-2*stride] = a - d1;
  43. src[-stride] = av_clip_uint8(b - d2);
  44. src[0] = av_clip_uint8(c + d2);
  45. src[stride] = d + d1;
  46. src++;
  47. rnd = !rnd;
  48. }
  49. }
  50. /** Apply overlap transform to vertical edge
  51. */
  52. static void vc1_h_overlap_c(uint8_t* src, int stride)
  53. {
  54. int i;
  55. int a, b, c, d;
  56. int d1, d2;
  57. int rnd = 1;
  58. for(i = 0; i < 8; i++) {
  59. a = src[-2];
  60. b = src[-1];
  61. c = src[0];
  62. d = src[1];
  63. d1 = (a - d + 3 + rnd) >> 3;
  64. d2 = (a - d + b - c + 4 - rnd) >> 3;
  65. src[-2] = a - d1;
  66. src[-1] = av_clip_uint8(b - d2);
  67. src[0] = av_clip_uint8(c + d2);
  68. src[1] = d + d1;
  69. src += stride;
  70. rnd = !rnd;
  71. }
  72. }
  73. /**
  74. * VC-1 in-loop deblocking filter for one line
  75. * @param src source block type
  76. * @param stride block stride
  77. * @param pq block quantizer
  78. * @return whether other 3 pairs should be filtered or not
  79. * @see 8.6
  80. */
  81. static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
  82. uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  83. int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
  84. int a0_sign = a0 >> 31; /* Store sign */
  85. a0 = (a0 ^ a0_sign) - a0_sign; /* a0 = FFABS(a0); */
  86. if(a0 < pq){
  87. int a1 = FFABS((2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3);
  88. int a2 = FFABS((2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3);
  89. if(a1 < a0 || a2 < a0){
  90. int clip = src[-1*stride] - src[ 0*stride];
  91. int clip_sign = clip >> 31;
  92. clip = ((clip ^ clip_sign) - clip_sign)>>1;
  93. if(clip){
  94. int a3 = FFMIN(a1, a2);
  95. int d = 5 * (a3 - a0);
  96. int d_sign = (d >> 31);
  97. d = ((d ^ d_sign) - d_sign) >> 3;
  98. d_sign ^= a0_sign;
  99. if( d_sign ^ clip_sign )
  100. d = 0;
  101. else{
  102. d = FFMIN(d, clip);
  103. d = (d ^ d_sign) - d_sign; /* Restore sign */
  104. src[-1*stride] = cm[src[-1*stride] - d];
  105. src[ 0*stride] = cm[src[ 0*stride] + d];
  106. }
  107. return 1;
  108. }
  109. }
  110. }
  111. return 0;
  112. }
  113. /**
  114. * VC-1 in-loop deblocking filter
  115. * @param src source block type
  116. * @param step distance between horizontally adjacent elements
  117. * @param stride distance between vertically adjacent elements
  118. * @param len edge length to filter (4 or 8 pixels)
  119. * @param pq block quantizer
  120. * @see 8.6
  121. */
  122. static inline void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq)
  123. {
  124. int i;
  125. int filt3;
  126. for(i = 0; i < len; i += 4){
  127. filt3 = vc1_filter_line(src + 2*step, stride, pq);
  128. if(filt3){
  129. vc1_filter_line(src + 0*step, stride, pq);
  130. vc1_filter_line(src + 1*step, stride, pq);
  131. vc1_filter_line(src + 3*step, stride, pq);
  132. }
  133. src += step * 4;
  134. }
  135. }
  136. static void vc1_v_loop_filter4_c(uint8_t *src, int stride, int pq)
  137. {
  138. vc1_loop_filter(src, 1, stride, 4, pq);
  139. }
  140. static void vc1_h_loop_filter4_c(uint8_t *src, int stride, int pq)
  141. {
  142. vc1_loop_filter(src, stride, 1, 4, pq);
  143. }
  144. static void vc1_v_loop_filter8_c(uint8_t *src, int stride, int pq)
  145. {
  146. vc1_loop_filter(src, 1, stride, 8, pq);
  147. }
  148. static void vc1_h_loop_filter8_c(uint8_t *src, int stride, int pq)
  149. {
  150. vc1_loop_filter(src, stride, 1, 8, pq);
  151. }
  152. static void vc1_v_loop_filter16_c(uint8_t *src, int stride, int pq)
  153. {
  154. vc1_loop_filter(src, 1, stride, 16, pq);
  155. }
  156. static void vc1_h_loop_filter16_c(uint8_t *src, int stride, int pq)
  157. {
  158. vc1_loop_filter(src, stride, 1, 16, pq);
  159. }
  160. /** Do inverse transform on 8x8 block
  161. */
  162. static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
  163. {
  164. int i;
  165. int dc = block[0];
  166. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  167. dc = (3 * dc + 1) >> 1;
  168. dc = (3 * dc + 16) >> 5;
  169. for(i = 0; i < 8; i++){
  170. dest[0] = cm[dest[0]+dc];
  171. dest[1] = cm[dest[1]+dc];
  172. dest[2] = cm[dest[2]+dc];
  173. dest[3] = cm[dest[3]+dc];
  174. dest[4] = cm[dest[4]+dc];
  175. dest[5] = cm[dest[5]+dc];
  176. dest[6] = cm[dest[6]+dc];
  177. dest[7] = cm[dest[7]+dc];
  178. dest += linesize;
  179. }
  180. }
  181. static void vc1_inv_trans_8x8_c(DCTELEM block[64])
  182. {
  183. int i;
  184. register int t1,t2,t3,t4,t5,t6,t7,t8;
  185. DCTELEM *src, *dst;
  186. src = block;
  187. dst = block;
  188. for(i = 0; i < 8; i++){
  189. t1 = 12 * (src[0] + src[4]) + 4;
  190. t2 = 12 * (src[0] - src[4]) + 4;
  191. t3 = 16 * src[2] + 6 * src[6];
  192. t4 = 6 * src[2] - 16 * src[6];
  193. t5 = t1 + t3;
  194. t6 = t2 + t4;
  195. t7 = t2 - t4;
  196. t8 = t1 - t3;
  197. t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
  198. t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
  199. t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
  200. t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
  201. dst[0] = (t5 + t1) >> 3;
  202. dst[1] = (t6 + t2) >> 3;
  203. dst[2] = (t7 + t3) >> 3;
  204. dst[3] = (t8 + t4) >> 3;
  205. dst[4] = (t8 - t4) >> 3;
  206. dst[5] = (t7 - t3) >> 3;
  207. dst[6] = (t6 - t2) >> 3;
  208. dst[7] = (t5 - t1) >> 3;
  209. src += 8;
  210. dst += 8;
  211. }
  212. src = block;
  213. dst = block;
  214. for(i = 0; i < 8; i++){
  215. t1 = 12 * (src[ 0] + src[32]) + 64;
  216. t2 = 12 * (src[ 0] - src[32]) + 64;
  217. t3 = 16 * src[16] + 6 * src[48];
  218. t4 = 6 * src[16] - 16 * src[48];
  219. t5 = t1 + t3;
  220. t6 = t2 + t4;
  221. t7 = t2 - t4;
  222. t8 = t1 - t3;
  223. t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
  224. t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
  225. t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
  226. t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
  227. dst[ 0] = (t5 + t1) >> 7;
  228. dst[ 8] = (t6 + t2) >> 7;
  229. dst[16] = (t7 + t3) >> 7;
  230. dst[24] = (t8 + t4) >> 7;
  231. dst[32] = (t8 - t4 + 1) >> 7;
  232. dst[40] = (t7 - t3 + 1) >> 7;
  233. dst[48] = (t6 - t2 + 1) >> 7;
  234. dst[56] = (t5 - t1 + 1) >> 7;
  235. src++;
  236. dst++;
  237. }
  238. }
  239. /** Do inverse transform on 8x4 part of block
  240. */
  241. static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
  242. {
  243. int i;
  244. int dc = block[0];
  245. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  246. dc = ( 3 * dc + 1) >> 1;
  247. dc = (17 * dc + 64) >> 7;
  248. for(i = 0; i < 4; i++){
  249. dest[0] = cm[dest[0]+dc];
  250. dest[1] = cm[dest[1]+dc];
  251. dest[2] = cm[dest[2]+dc];
  252. dest[3] = cm[dest[3]+dc];
  253. dest[4] = cm[dest[4]+dc];
  254. dest[5] = cm[dest[5]+dc];
  255. dest[6] = cm[dest[6]+dc];
  256. dest[7] = cm[dest[7]+dc];
  257. dest += linesize;
  258. }
  259. }
  260. static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, DCTELEM *block)
  261. {
  262. int i;
  263. register int t1,t2,t3,t4,t5,t6,t7,t8;
  264. DCTELEM *src, *dst;
  265. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  266. src = block;
  267. dst = block;
  268. for(i = 0; i < 4; i++){
  269. t1 = 12 * (src[0] + src[4]) + 4;
  270. t2 = 12 * (src[0] - src[4]) + 4;
  271. t3 = 16 * src[2] + 6 * src[6];
  272. t4 = 6 * src[2] - 16 * src[6];
  273. t5 = t1 + t3;
  274. t6 = t2 + t4;
  275. t7 = t2 - t4;
  276. t8 = t1 - t3;
  277. t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
  278. t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
  279. t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
  280. t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
  281. dst[0] = (t5 + t1) >> 3;
  282. dst[1] = (t6 + t2) >> 3;
  283. dst[2] = (t7 + t3) >> 3;
  284. dst[3] = (t8 + t4) >> 3;
  285. dst[4] = (t8 - t4) >> 3;
  286. dst[5] = (t7 - t3) >> 3;
  287. dst[6] = (t6 - t2) >> 3;
  288. dst[7] = (t5 - t1) >> 3;
  289. src += 8;
  290. dst += 8;
  291. }
  292. src = block;
  293. for(i = 0; i < 8; i++){
  294. t1 = 17 * (src[ 0] + src[16]) + 64;
  295. t2 = 17 * (src[ 0] - src[16]) + 64;
  296. t3 = 22 * src[ 8] + 10 * src[24];
  297. t4 = 22 * src[24] - 10 * src[ 8];
  298. dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
  299. dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
  300. dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
  301. dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
  302. src ++;
  303. dest++;
  304. }
  305. }
  306. /** Do inverse transform on 4x8 parts of block
  307. */
  308. static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
  309. {
  310. int i;
  311. int dc = block[0];
  312. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  313. dc = (17 * dc + 4) >> 3;
  314. dc = (12 * dc + 64) >> 7;
  315. for(i = 0; i < 8; i++){
  316. dest[0] = cm[dest[0]+dc];
  317. dest[1] = cm[dest[1]+dc];
  318. dest[2] = cm[dest[2]+dc];
  319. dest[3] = cm[dest[3]+dc];
  320. dest += linesize;
  321. }
  322. }
  323. static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block)
  324. {
  325. int i;
  326. register int t1,t2,t3,t4,t5,t6,t7,t8;
  327. DCTELEM *src, *dst;
  328. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  329. src = block;
  330. dst = block;
  331. for(i = 0; i < 8; i++){
  332. t1 = 17 * (src[0] + src[2]) + 4;
  333. t2 = 17 * (src[0] - src[2]) + 4;
  334. t3 = 22 * src[1] + 10 * src[3];
  335. t4 = 22 * src[3] - 10 * src[1];
  336. dst[0] = (t1 + t3) >> 3;
  337. dst[1] = (t2 - t4) >> 3;
  338. dst[2] = (t2 + t4) >> 3;
  339. dst[3] = (t1 - t3) >> 3;
  340. src += 8;
  341. dst += 8;
  342. }
  343. src = block;
  344. for(i = 0; i < 4; i++){
  345. t1 = 12 * (src[ 0] + src[32]) + 64;
  346. t2 = 12 * (src[ 0] - src[32]) + 64;
  347. t3 = 16 * src[16] + 6 * src[48];
  348. t4 = 6 * src[16] - 16 * src[48];
  349. t5 = t1 + t3;
  350. t6 = t2 + t4;
  351. t7 = t2 - t4;
  352. t8 = t1 - t3;
  353. t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
  354. t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
  355. t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
  356. t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
  357. dest[0*linesize] = cm[dest[0*linesize] + ((t5 + t1) >> 7)];
  358. dest[1*linesize] = cm[dest[1*linesize] + ((t6 + t2) >> 7)];
  359. dest[2*linesize] = cm[dest[2*linesize] + ((t7 + t3) >> 7)];
  360. dest[3*linesize] = cm[dest[3*linesize] + ((t8 + t4) >> 7)];
  361. dest[4*linesize] = cm[dest[4*linesize] + ((t8 - t4 + 1) >> 7)];
  362. dest[5*linesize] = cm[dest[5*linesize] + ((t7 - t3 + 1) >> 7)];
  363. dest[6*linesize] = cm[dest[6*linesize] + ((t6 - t2 + 1) >> 7)];
  364. dest[7*linesize] = cm[dest[7*linesize] + ((t5 - t1 + 1) >> 7)];
  365. src ++;
  366. dest++;
  367. }
  368. }
  369. /** Do inverse transform on 4x4 part of block
  370. */
  371. static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
  372. {
  373. int i;
  374. int dc = block[0];
  375. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  376. dc = (17 * dc + 4) >> 3;
  377. dc = (17 * dc + 64) >> 7;
  378. for(i = 0; i < 4; i++){
  379. dest[0] = cm[dest[0]+dc];
  380. dest[1] = cm[dest[1]+dc];
  381. dest[2] = cm[dest[2]+dc];
  382. dest[3] = cm[dest[3]+dc];
  383. dest += linesize;
  384. }
  385. }
  386. static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
  387. {
  388. int i;
  389. register int t1,t2,t3,t4;
  390. DCTELEM *src, *dst;
  391. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  392. src = block;
  393. dst = block;
  394. for(i = 0; i < 4; i++){
  395. t1 = 17 * (src[0] + src[2]) + 4;
  396. t2 = 17 * (src[0] - src[2]) + 4;
  397. t3 = 22 * src[1] + 10 * src[3];
  398. t4 = 22 * src[3] - 10 * src[1];
  399. dst[0] = (t1 + t3) >> 3;
  400. dst[1] = (t2 - t4) >> 3;
  401. dst[2] = (t2 + t4) >> 3;
  402. dst[3] = (t1 - t3) >> 3;
  403. src += 8;
  404. dst += 8;
  405. }
  406. src = block;
  407. for(i = 0; i < 4; i++){
  408. t1 = 17 * (src[ 0] + src[16]) + 64;
  409. t2 = 17 * (src[ 0] - src[16]) + 64;
  410. t3 = 22 * src[ 8] + 10 * src[24];
  411. t4 = 22 * src[24] - 10 * src[ 8];
  412. dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
  413. dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
  414. dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
  415. dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
  416. src ++;
  417. dest++;
  418. }
  419. }
  420. /* motion compensation functions */
  421. /** Filter in case of 2 filters */
  422. #define VC1_MSPEL_FILTER_16B(DIR, TYPE) \
  423. static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, int stride, int mode) \
  424. { \
  425. switch(mode){ \
  426. case 0: /* no shift - should not occur */ \
  427. return 0; \
  428. case 1: /* 1/4 shift */ \
  429. return -4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2]; \
  430. case 2: /* 1/2 shift */ \
  431. return -src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2]; \
  432. case 3: /* 3/4 shift */ \
  433. return -3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2]; \
  434. } \
  435. return 0; /* should not occur */ \
  436. }
  437. VC1_MSPEL_FILTER_16B(ver, uint8_t);
  438. VC1_MSPEL_FILTER_16B(hor, int16_t);
  439. /** Filter used to interpolate fractional pel values
  440. */
  441. static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
  442. {
  443. switch(mode){
  444. case 0: //no shift
  445. return src[0];
  446. case 1: // 1/4 shift
  447. return (-4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2] + 32 - r) >> 6;
  448. case 2: // 1/2 shift
  449. return (-src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2] + 8 - r) >> 4;
  450. case 3: // 3/4 shift
  451. return (-3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2] + 32 - r) >> 6;
  452. }
  453. return 0; //should not occur
  454. }
  455. /** Function used to do motion compensation with bicubic interpolation
  456. */
  457. #define VC1_MSPEL_MC(OP, OPNAME)\
  458. static void OPNAME ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)\
  459. {\
  460. int i, j;\
  461. \
  462. if (vmode) { /* Horizontal filter to apply */\
  463. int r;\
  464. \
  465. if (hmode) { /* Vertical filter to apply, output to tmp */\
  466. static const int shift_value[] = { 0, 5, 1, 5 };\
  467. int shift = (shift_value[hmode]+shift_value[vmode])>>1;\
  468. int16_t tmp[11*8], *tptr = tmp;\
  469. \
  470. r = (1<<(shift-1)) + rnd-1;\
  471. \
  472. src -= 1;\
  473. for(j = 0; j < 8; j++) {\
  474. for(i = 0; i < 11; i++)\
  475. tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift;\
  476. src += stride;\
  477. tptr += 11;\
  478. }\
  479. \
  480. r = 64-rnd;\
  481. tptr = tmp+1;\
  482. for(j = 0; j < 8; j++) {\
  483. for(i = 0; i < 8; i++)\
  484. OP(dst[i], (vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7);\
  485. dst += stride;\
  486. tptr += 11;\
  487. }\
  488. \
  489. return;\
  490. }\
  491. else { /* No horizontal filter, output 8 lines to dst */\
  492. r = 1-rnd;\
  493. \
  494. for(j = 0; j < 8; j++) {\
  495. for(i = 0; i < 8; i++)\
  496. OP(dst[i], vc1_mspel_filter(src + i, stride, vmode, r));\
  497. src += stride;\
  498. dst += stride;\
  499. }\
  500. return;\
  501. }\
  502. }\
  503. \
  504. /* Horizontal mode with no vertical mode */\
  505. for(j = 0; j < 8; j++) {\
  506. for(i = 0; i < 8; i++)\
  507. OP(dst[i], vc1_mspel_filter(src + i, 1, hmode, rnd));\
  508. dst += stride;\
  509. src += stride;\
  510. }\
  511. }
  512. #define op_put(a, b) a = av_clip_uint8(b)
  513. #define op_avg(a, b) a = (a + av_clip_uint8(b) + 1) >> 1
  514. VC1_MSPEL_MC(op_put, put_)
  515. VC1_MSPEL_MC(op_avg, avg_)
  516. /* pixel functions - really are entry points to vc1_mspel_mc */
  517. /* this one is defined in dsputil.c */
  518. void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
  519. void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
  520. #define PUT_VC1_MSPEL(a, b)\
  521. static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
  522. put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
  523. }\
  524. static void avg_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
  525. avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
  526. }
  527. PUT_VC1_MSPEL(1, 0)
  528. PUT_VC1_MSPEL(2, 0)
  529. PUT_VC1_MSPEL(3, 0)
  530. PUT_VC1_MSPEL(0, 1)
  531. PUT_VC1_MSPEL(1, 1)
  532. PUT_VC1_MSPEL(2, 1)
  533. PUT_VC1_MSPEL(3, 1)
  534. PUT_VC1_MSPEL(0, 2)
  535. PUT_VC1_MSPEL(1, 2)
  536. PUT_VC1_MSPEL(2, 2)
  537. PUT_VC1_MSPEL(3, 2)
  538. PUT_VC1_MSPEL(0, 3)
  539. PUT_VC1_MSPEL(1, 3)
  540. PUT_VC1_MSPEL(2, 3)
  541. PUT_VC1_MSPEL(3, 3)
  542. void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
  543. dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
  544. dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
  545. dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
  546. dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
  547. dsp->vc1_inv_trans_8x8_dc = vc1_inv_trans_8x8_dc_c;
  548. dsp->vc1_inv_trans_4x8_dc = vc1_inv_trans_4x8_dc_c;
  549. dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_c;
  550. dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_c;
  551. dsp->vc1_h_overlap = vc1_h_overlap_c;
  552. dsp->vc1_v_overlap = vc1_v_overlap_c;
  553. dsp->vc1_v_loop_filter4 = vc1_v_loop_filter4_c;
  554. dsp->vc1_h_loop_filter4 = vc1_h_loop_filter4_c;
  555. dsp->vc1_v_loop_filter8 = vc1_v_loop_filter8_c;
  556. dsp->vc1_h_loop_filter8 = vc1_h_loop_filter8_c;
  557. dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_c;
  558. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_c;
  559. dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_c;
  560. dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_c;
  561. dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_c;
  562. dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_c;
  563. dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_c;
  564. dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_c;
  565. dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_c;
  566. dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_c;
  567. dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_c;
  568. dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_c;
  569. dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_c;
  570. dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_c;
  571. dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_c;
  572. dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_c;
  573. dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c;
  574. dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c;
  575. dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_vc1_mspel_mc00_c;
  576. dsp->avg_vc1_mspel_pixels_tab[ 1] = avg_vc1_mspel_mc10_c;
  577. dsp->avg_vc1_mspel_pixels_tab[ 2] = avg_vc1_mspel_mc20_c;
  578. dsp->avg_vc1_mspel_pixels_tab[ 3] = avg_vc1_mspel_mc30_c;
  579. dsp->avg_vc1_mspel_pixels_tab[ 4] = avg_vc1_mspel_mc01_c;
  580. dsp->avg_vc1_mspel_pixels_tab[ 5] = avg_vc1_mspel_mc11_c;
  581. dsp->avg_vc1_mspel_pixels_tab[ 6] = avg_vc1_mspel_mc21_c;
  582. dsp->avg_vc1_mspel_pixels_tab[ 7] = avg_vc1_mspel_mc31_c;
  583. dsp->avg_vc1_mspel_pixels_tab[ 8] = avg_vc1_mspel_mc02_c;
  584. dsp->avg_vc1_mspel_pixels_tab[ 9] = avg_vc1_mspel_mc12_c;
  585. dsp->avg_vc1_mspel_pixels_tab[10] = avg_vc1_mspel_mc22_c;
  586. dsp->avg_vc1_mspel_pixels_tab[11] = avg_vc1_mspel_mc32_c;
  587. dsp->avg_vc1_mspel_pixels_tab[12] = avg_vc1_mspel_mc03_c;
  588. dsp->avg_vc1_mspel_pixels_tab[13] = avg_vc1_mspel_mc13_c;
  589. dsp->avg_vc1_mspel_pixels_tab[14] = avg_vc1_mspel_mc23_c;
  590. dsp->avg_vc1_mspel_pixels_tab[15] = avg_vc1_mspel_mc33_c;
  591. }