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.

572 lines
18KB

  1. /*
  2. * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
  3. * Copyright (C) 2008 David Conrad
  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. #include "libavutil/attributes.h"
  22. #include "libavutil/avassert.h"
  23. #include "libavutil/common.h"
  24. #include "dsputil.h"
  25. #include "dirac_dwt.h"
  26. #include "libavcodec/x86/dirac_dwt.h"
  27. static inline int mirror(int v, int m)
  28. {
  29. while ((unsigned)v > (unsigned)m) {
  30. v = -v;
  31. if (v < 0)
  32. v += 2 * m;
  33. }
  34. return v;
  35. }
  36. static void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
  37. int width)
  38. {
  39. int i;
  40. for (i = 0; i < width; i++)
  41. b1[i] -= (b0[i] + b2[i] + 2) >> 2;
  42. }
  43. static av_always_inline
  44. void interleave(IDWTELEM *dst, IDWTELEM *src0, IDWTELEM *src1, int w2, int add, int shift)
  45. {
  46. int i;
  47. for (i = 0; i < w2; i++) {
  48. dst[2*i ] = (src0[i] + add) >> shift;
  49. dst[2*i+1] = (src1[i] + add) >> shift;
  50. }
  51. }
  52. static void horizontal_compose_dirac53i(IDWTELEM *b, IDWTELEM *temp, int w)
  53. {
  54. const int w2 = w >> 1;
  55. int x;
  56. temp[0] = COMPOSE_53iL0(b[w2], b[0], b[w2]);
  57. for (x = 1; x < w2; x++) {
  58. temp[x ] = COMPOSE_53iL0 (b[x+w2-1], b[x ], b[x+w2]);
  59. temp[x+w2-1] = COMPOSE_DIRAC53iH0(temp[x-1], b[x+w2-1], temp[x]);
  60. }
  61. temp[w-1] = COMPOSE_DIRAC53iH0(temp[w2-1], b[w-1], temp[w2-1]);
  62. interleave(b, temp, temp+w2, w2, 1, 1);
  63. }
  64. static void horizontal_compose_dd97i(IDWTELEM *b, IDWTELEM *tmp, int w)
  65. {
  66. const int w2 = w >> 1;
  67. int x;
  68. tmp[0] = COMPOSE_53iL0(b[w2], b[0], b[w2]);
  69. for (x = 1; x < w2; x++)
  70. tmp[x] = COMPOSE_53iL0(b[x+w2-1], b[x], b[x+w2]);
  71. // extend the edges
  72. tmp[-1] = tmp[0];
  73. tmp[w2+1] = tmp[w2] = tmp[w2-1];
  74. for (x = 0; x < w2; x++) {
  75. b[2*x ] = (tmp[x] + 1)>>1;
  76. b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1;
  77. }
  78. }
  79. static void horizontal_compose_dd137i(IDWTELEM *b, IDWTELEM *tmp, int w)
  80. {
  81. const int w2 = w >> 1;
  82. int x;
  83. tmp[0] = COMPOSE_DD137iL0(b[w2], b[w2], b[0], b[w2 ], b[w2+1]);
  84. tmp[1] = COMPOSE_DD137iL0(b[w2], b[w2], b[1], b[w2+1], b[w2+2]);
  85. for (x = 2; x < w2-1; x++)
  86. tmp[x] = COMPOSE_DD137iL0(b[x+w2-2], b[x+w2-1], b[x], b[x+w2], b[x+w2+1]);
  87. tmp[w2-1] = COMPOSE_DD137iL0(b[w-3], b[w-2], b[w2-1], b[w-1], b[w-1]);
  88. // extend the edges
  89. tmp[-1] = tmp[0];
  90. tmp[w2+1] = tmp[w2] = tmp[w2-1];
  91. for (x = 0; x < w2; x++) {
  92. b[2*x ] = (tmp[x] + 1)>>1;
  93. b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1;
  94. }
  95. }
  96. static av_always_inline
  97. void horizontal_compose_haari(IDWTELEM *b, IDWTELEM *temp, int w, int shift)
  98. {
  99. const int w2 = w >> 1;
  100. int x;
  101. for (x = 0; x < w2; x++) {
  102. temp[x ] = COMPOSE_HAARiL0(b[x ], b[x+w2]);
  103. temp[x+w2] = COMPOSE_HAARiH0(b[x+w2], temp[x]);
  104. }
  105. interleave(b, temp, temp+w2, w2, shift, shift);
  106. }
  107. static void horizontal_compose_haar0i(IDWTELEM *b, IDWTELEM *temp, int w)
  108. {
  109. horizontal_compose_haari(b, temp, w, 0);
  110. }
  111. static void horizontal_compose_haar1i(IDWTELEM *b, IDWTELEM *temp, int w)
  112. {
  113. horizontal_compose_haari(b, temp, w, 1);
  114. }
  115. static void horizontal_compose_fidelityi(IDWTELEM *b, IDWTELEM *tmp, int w)
  116. {
  117. const int w2 = w >> 1;
  118. int i, x;
  119. IDWTELEM v[8];
  120. for (x = 0; x < w2; x++) {
  121. for (i = 0; i < 8; i++)
  122. v[i] = b[av_clip(x-3+i, 0, w2-1)];
  123. tmp[x] = COMPOSE_FIDELITYiH0(v[0], v[1], v[2], v[3], b[x+w2], v[4], v[5], v[6], v[7]);
  124. }
  125. for (x = 0; x < w2; x++) {
  126. for (i = 0; i < 8; i++)
  127. v[i] = tmp[av_clip(x-4+i, 0, w2-1)];
  128. tmp[x+w2] = COMPOSE_FIDELITYiL0(v[0], v[1], v[2], v[3], b[x], v[4], v[5], v[6], v[7]);
  129. }
  130. interleave(b, tmp+w2, tmp, w2, 0, 0);
  131. }
  132. static void horizontal_compose_daub97i(IDWTELEM *b, IDWTELEM *temp, int w)
  133. {
  134. const int w2 = w >> 1;
  135. int x, b0, b1, b2;
  136. temp[0] = COMPOSE_DAUB97iL1(b[w2], b[0], b[w2]);
  137. for (x = 1; x < w2; x++) {
  138. temp[x ] = COMPOSE_DAUB97iL1(b[x+w2-1], b[x ], b[x+w2]);
  139. temp[x+w2-1] = COMPOSE_DAUB97iH1(temp[x-1], b[x+w2-1], temp[x]);
  140. }
  141. temp[w-1] = COMPOSE_DAUB97iH1(temp[w2-1], b[w-1], temp[w2-1]);
  142. // second stage combined with interleave and shift
  143. b0 = b2 = COMPOSE_DAUB97iL0(temp[w2], temp[0], temp[w2]);
  144. b[0] = (b0 + 1) >> 1;
  145. for (x = 1; x < w2; x++) {
  146. b2 = COMPOSE_DAUB97iL0(temp[x+w2-1], temp[x ], temp[x+w2]);
  147. b1 = COMPOSE_DAUB97iH0( b0, temp[x+w2-1], b2 );
  148. b[2*x-1] = (b1 + 1) >> 1;
  149. b[2*x ] = (b2 + 1) >> 1;
  150. b0 = b2;
  151. }
  152. b[w-1] = (COMPOSE_DAUB97iH0(b2, temp[w-1], b2) + 1) >> 1;
  153. }
  154. static void vertical_compose_dirac53iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
  155. {
  156. int i;
  157. for(i=0; i<width; i++){
  158. b1[i] = COMPOSE_DIRAC53iH0(b0[i], b1[i], b2[i]);
  159. }
  160. }
  161. static void vertical_compose_dd97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
  162. IDWTELEM *b3, IDWTELEM *b4, int width)
  163. {
  164. int i;
  165. for(i=0; i<width; i++){
  166. b2[i] = COMPOSE_DD97iH0(b0[i], b1[i], b2[i], b3[i], b4[i]);
  167. }
  168. }
  169. static void vertical_compose_dd137iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
  170. IDWTELEM *b3, IDWTELEM *b4, int width)
  171. {
  172. int i;
  173. for(i=0; i<width; i++){
  174. b2[i] = COMPOSE_DD137iL0(b0[i], b1[i], b2[i], b3[i], b4[i]);
  175. }
  176. }
  177. static void vertical_compose_haar(IDWTELEM *b0, IDWTELEM *b1, int width)
  178. {
  179. int i;
  180. for (i = 0; i < width; i++) {
  181. b0[i] = COMPOSE_HAARiL0(b0[i], b1[i]);
  182. b1[i] = COMPOSE_HAARiH0(b1[i], b0[i]);
  183. }
  184. }
  185. static void vertical_compose_fidelityiH0(IDWTELEM *dst, IDWTELEM *b[8], int width)
  186. {
  187. int i;
  188. for(i=0; i<width; i++){
  189. dst[i] = COMPOSE_FIDELITYiH0(b[0][i], b[1][i], b[2][i], b[3][i], dst[i], b[4][i], b[5][i], b[6][i], b[7][i]);
  190. }
  191. }
  192. static void vertical_compose_fidelityiL0(IDWTELEM *dst, IDWTELEM *b[8], int width)
  193. {
  194. int i;
  195. for(i=0; i<width; i++){
  196. dst[i] = COMPOSE_FIDELITYiL0(b[0][i], b[1][i], b[2][i], b[3][i], dst[i], b[4][i], b[5][i], b[6][i], b[7][i]);
  197. }
  198. }
  199. static void vertical_compose_daub97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
  200. {
  201. int i;
  202. for(i=0; i<width; i++){
  203. b1[i] = COMPOSE_DAUB97iH0(b0[i], b1[i], b2[i]);
  204. }
  205. }
  206. static void vertical_compose_daub97iH1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
  207. {
  208. int i;
  209. for(i=0; i<width; i++){
  210. b1[i] = COMPOSE_DAUB97iH1(b0[i], b1[i], b2[i]);
  211. }
  212. }
  213. static void vertical_compose_daub97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
  214. {
  215. int i;
  216. for(i=0; i<width; i++){
  217. b1[i] = COMPOSE_DAUB97iL0(b0[i], b1[i], b2[i]);
  218. }
  219. }
  220. static void vertical_compose_daub97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
  221. {
  222. int i;
  223. for(i=0; i<width; i++){
  224. b1[i] = COMPOSE_DAUB97iL1(b0[i], b1[i], b2[i]);
  225. }
  226. }
  227. static void spatial_compose_dd97i_dy(DWTContext *d, int level, int width, int height, int stride)
  228. {
  229. vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
  230. vertical_compose_5tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
  231. DWTCompose *cs = d->cs + level;
  232. int i, y = cs->y;
  233. IDWTELEM *b[8];
  234. for (i = 0; i < 6; i++)
  235. b[i] = cs->b[i];
  236. b[6] = d->buffer + av_clip(y+5, 0, height-2)*stride;
  237. b[7] = d->buffer + av_clip(y+6, 1, height-1)*stride;
  238. if(y+5<(unsigned)height) vertical_compose_l0( b[5], b[6], b[7], width);
  239. if(y+1<(unsigned)height) vertical_compose_h0(b[0], b[2], b[3], b[4], b[6], width);
  240. if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width);
  241. if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width);
  242. for (i = 0; i < 6; i++)
  243. cs->b[i] = b[i+2];
  244. cs->y += 2;
  245. }
  246. static void spatial_compose_dirac53i_dy(DWTContext *d, int level, int width, int height, int stride)
  247. {
  248. vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
  249. vertical_compose_3tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
  250. DWTCompose *cs = d->cs + level;
  251. int y= cs->y;
  252. IDWTELEM *b[4] = { cs->b[0], cs->b[1] };
  253. b[2] = d->buffer + mirror(y+1, height-1)*stride;
  254. b[3] = d->buffer + mirror(y+2, height-1)*stride;
  255. if(y+1<(unsigned)height) vertical_compose_l0(b[1], b[2], b[3], width);
  256. if(y+0<(unsigned)height) vertical_compose_h0(b[0], b[1], b[2], width);
  257. if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width);
  258. if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width);
  259. cs->b[0] = b[2];
  260. cs->b[1] = b[3];
  261. cs->y += 2;
  262. }
  263. static void spatial_compose_dd137i_dy(DWTContext *d, int level, int width, int height, int stride)
  264. {
  265. vertical_compose_5tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
  266. vertical_compose_5tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
  267. DWTCompose *cs = d->cs + level;
  268. int i, y = cs->y;
  269. IDWTELEM *b[10];
  270. for (i = 0; i < 8; i++)
  271. b[i] = cs->b[i];
  272. b[8] = d->buffer + av_clip(y+7, 0, height-2)*stride;
  273. b[9] = d->buffer + av_clip(y+8, 1, height-1)*stride;
  274. if(y+5<(unsigned)height) vertical_compose_l0(b[3], b[5], b[6], b[7], b[9], width);
  275. if(y+1<(unsigned)height) vertical_compose_h0(b[0], b[2], b[3], b[4], b[6], width);
  276. if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width);
  277. if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width);
  278. for (i = 0; i < 8; i++)
  279. cs->b[i] = b[i+2];
  280. cs->y += 2;
  281. }
  282. // haar makes the assumption that height is even (always true for dirac)
  283. static void spatial_compose_haari_dy(DWTContext *d, int level, int width, int height, int stride)
  284. {
  285. vertical_compose_2tap vertical_compose = (void*)d->vertical_compose;
  286. int y = d->cs[level].y;
  287. IDWTELEM *b0 = d->buffer + (y-1)*stride;
  288. IDWTELEM *b1 = d->buffer + (y )*stride;
  289. vertical_compose(b0, b1, width);
  290. d->horizontal_compose(b0, d->temp, width);
  291. d->horizontal_compose(b1, d->temp, width);
  292. d->cs[level].y += 2;
  293. }
  294. // Don't do sliced idwt for fidelity; the 9 tap filter makes it a bit annoying
  295. // Fortunately, this filter isn't used in practice.
  296. static void spatial_compose_fidelity(DWTContext *d, int level, int width, int height, int stride)
  297. {
  298. vertical_compose_9tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
  299. vertical_compose_9tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
  300. int i, y;
  301. IDWTELEM *b[8];
  302. for (y = 1; y < height; y += 2) {
  303. for (i = 0; i < 8; i++)
  304. b[i] = d->buffer + av_clip((y-7 + 2*i), 0, height-2)*stride;
  305. vertical_compose_h0(d->buffer + y*stride, b, width);
  306. }
  307. for (y = 0; y < height; y += 2) {
  308. for (i = 0; i < 8; i++)
  309. b[i] = d->buffer + av_clip((y-7 + 2*i), 1, height-1)*stride;
  310. vertical_compose_l0(d->buffer + y*stride, b, width);
  311. }
  312. for (y = 0; y < height; y++)
  313. d->horizontal_compose(d->buffer + y*stride, d->temp, width);
  314. d->cs[level].y = height+1;
  315. }
  316. static void spatial_compose_daub97i_dy(DWTContext *d, int level, int width, int height, int stride)
  317. {
  318. vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
  319. vertical_compose_3tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
  320. vertical_compose_3tap vertical_compose_l1 = (void*)d->vertical_compose_l1;
  321. vertical_compose_3tap vertical_compose_h1 = (void*)d->vertical_compose_h1;
  322. DWTCompose *cs = d->cs + level;
  323. int i, y = cs->y;
  324. IDWTELEM *b[6];
  325. for (i = 0; i < 4; i++)
  326. b[i] = cs->b[i];
  327. b[4] = d->buffer + mirror(y+3, height-1)*stride;
  328. b[5] = d->buffer + mirror(y+4, height-1)*stride;
  329. if(y+3<(unsigned)height) vertical_compose_l1(b[3], b[4], b[5], width);
  330. if(y+2<(unsigned)height) vertical_compose_h1(b[2], b[3], b[4], width);
  331. if(y+1<(unsigned)height) vertical_compose_l0(b[1], b[2], b[3], width);
  332. if(y+0<(unsigned)height) vertical_compose_h0(b[0], b[1], b[2], width);
  333. if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width);
  334. if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width);
  335. for (i = 0; i < 4; i++)
  336. cs->b[i] = b[i+2];
  337. cs->y += 2;
  338. }
  339. static void spatial_compose97i_init2(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
  340. {
  341. cs->b[0] = buffer + mirror(-3-1, height-1)*stride;
  342. cs->b[1] = buffer + mirror(-3 , height-1)*stride;
  343. cs->b[2] = buffer + mirror(-3+1, height-1)*stride;
  344. cs->b[3] = buffer + mirror(-3+2, height-1)*stride;
  345. cs->y = -3;
  346. }
  347. static void spatial_compose53i_init2(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
  348. {
  349. cs->b[0] = buffer + mirror(-1-1, height-1)*stride;
  350. cs->b[1] = buffer + mirror(-1 , height-1)*stride;
  351. cs->y = -1;
  352. }
  353. static void spatial_compose_dd97i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
  354. {
  355. cs->b[0] = buffer + av_clip(-5-1, 0, height-2)*stride;
  356. cs->b[1] = buffer + av_clip(-5 , 1, height-1)*stride;
  357. cs->b[2] = buffer + av_clip(-5+1, 0, height-2)*stride;
  358. cs->b[3] = buffer + av_clip(-5+2, 1, height-1)*stride;
  359. cs->b[4] = buffer + av_clip(-5+3, 0, height-2)*stride;
  360. cs->b[5] = buffer + av_clip(-5+4, 1, height-1)*stride;
  361. cs->y = -5;
  362. }
  363. static void spatial_compose_dd137i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
  364. {
  365. cs->b[0] = buffer + av_clip(-5-1, 0, height-2)*stride;
  366. cs->b[1] = buffer + av_clip(-5 , 1, height-1)*stride;
  367. cs->b[2] = buffer + av_clip(-5+1, 0, height-2)*stride;
  368. cs->b[3] = buffer + av_clip(-5+2, 1, height-1)*stride;
  369. cs->b[4] = buffer + av_clip(-5+3, 0, height-2)*stride;
  370. cs->b[5] = buffer + av_clip(-5+4, 1, height-1)*stride;
  371. cs->b[6] = buffer + av_clip(-5+5, 0, height-2)*stride;
  372. cs->b[7] = buffer + av_clip(-5+6, 1, height-1)*stride;
  373. cs->y = -5;
  374. }
  375. int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height,
  376. int stride, enum dwt_type type, int decomposition_count,
  377. IDWTELEM *temp)
  378. {
  379. int level;
  380. d->buffer = buffer;
  381. d->width = width;
  382. d->height = height;
  383. d->stride = stride;
  384. d->decomposition_count = decomposition_count;
  385. d->temp = temp + 8;
  386. for(level=decomposition_count-1; level>=0; level--){
  387. int hl = height >> level;
  388. int stride_l = stride << level;
  389. switch(type){
  390. case DWT_DIRAC_DD9_7:
  391. spatial_compose_dd97i_init(d->cs+level, buffer, hl, stride_l);
  392. break;
  393. case DWT_DIRAC_LEGALL5_3:
  394. spatial_compose53i_init2(d->cs+level, buffer, hl, stride_l);
  395. break;
  396. case DWT_DIRAC_DD13_7:
  397. spatial_compose_dd137i_init(d->cs+level, buffer, hl, stride_l);
  398. break;
  399. case DWT_DIRAC_HAAR0:
  400. case DWT_DIRAC_HAAR1:
  401. d->cs[level].y = 1;
  402. break;
  403. case DWT_DIRAC_DAUB9_7:
  404. spatial_compose97i_init2(d->cs+level, buffer, hl, stride_l);
  405. break;
  406. default:
  407. d->cs[level].y = 0;
  408. break;
  409. }
  410. }
  411. switch (type) {
  412. case DWT_DIRAC_DD9_7:
  413. d->spatial_compose = spatial_compose_dd97i_dy;
  414. d->vertical_compose_l0 = (void*)vertical_compose53iL0;
  415. d->vertical_compose_h0 = (void*)vertical_compose_dd97iH0;
  416. d->horizontal_compose = horizontal_compose_dd97i;
  417. d->support = 7;
  418. break;
  419. case DWT_DIRAC_LEGALL5_3:
  420. d->spatial_compose = spatial_compose_dirac53i_dy;
  421. d->vertical_compose_l0 = (void*)vertical_compose53iL0;
  422. d->vertical_compose_h0 = (void*)vertical_compose_dirac53iH0;
  423. d->horizontal_compose = horizontal_compose_dirac53i;
  424. d->support = 3;
  425. break;
  426. case DWT_DIRAC_DD13_7:
  427. d->spatial_compose = spatial_compose_dd137i_dy;
  428. d->vertical_compose_l0 = (void*)vertical_compose_dd137iL0;
  429. d->vertical_compose_h0 = (void*)vertical_compose_dd97iH0;
  430. d->horizontal_compose = horizontal_compose_dd137i;
  431. d->support = 7;
  432. break;
  433. case DWT_DIRAC_HAAR0:
  434. case DWT_DIRAC_HAAR1:
  435. d->spatial_compose = spatial_compose_haari_dy;
  436. d->vertical_compose = (void*)vertical_compose_haar;
  437. if (type == DWT_DIRAC_HAAR0)
  438. d->horizontal_compose = horizontal_compose_haar0i;
  439. else
  440. d->horizontal_compose = horizontal_compose_haar1i;
  441. d->support = 1;
  442. break;
  443. case DWT_DIRAC_FIDELITY:
  444. d->spatial_compose = spatial_compose_fidelity;
  445. d->vertical_compose_l0 = (void*)vertical_compose_fidelityiL0;
  446. d->vertical_compose_h0 = (void*)vertical_compose_fidelityiH0;
  447. d->horizontal_compose = horizontal_compose_fidelityi;
  448. break;
  449. case DWT_DIRAC_DAUB9_7:
  450. d->spatial_compose = spatial_compose_daub97i_dy;
  451. d->vertical_compose_l0 = (void*)vertical_compose_daub97iL0;
  452. d->vertical_compose_h0 = (void*)vertical_compose_daub97iH0;
  453. d->vertical_compose_l1 = (void*)vertical_compose_daub97iL1;
  454. d->vertical_compose_h1 = (void*)vertical_compose_daub97iH1;
  455. d->horizontal_compose = horizontal_compose_daub97i;
  456. d->support = 5;
  457. break;
  458. default:
  459. av_log(NULL, AV_LOG_ERROR, "Unknown wavelet type %d\n", type);
  460. return -1;
  461. }
  462. if (HAVE_MMX) ff_spatial_idwt_init_mmx(d, type);
  463. return 0;
  464. }
  465. void ff_spatial_idwt_slice2(DWTContext *d, int y)
  466. {
  467. int level, support = d->support;
  468. for (level = d->decomposition_count-1; level >= 0; level--) {
  469. int wl = d->width >> level;
  470. int hl = d->height >> level;
  471. int stride_l = d->stride << level;
  472. while (d->cs[level].y <= FFMIN((y>>level)+support, hl))
  473. d->spatial_compose(d, level, wl, hl, stride_l);
  474. }
  475. }