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.

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