postprocess.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. /*
  2. * Copyright (C) 2001-2003 Michael Niedermayer (michaelni@gmx.at)
  3. *
  4. * AltiVec optimizations (C) 2004 Romain Dolbeau <romain@dolbeau.org>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * postprocessing.
  25. */
  26. /*
  27. C MMX MMX2 3DNow AltiVec
  28. isVertDC Ec Ec Ec
  29. isVertMinMaxOk Ec Ec Ec
  30. doVertLowPass E e e Ec
  31. doVertDefFilter Ec Ec e e Ec
  32. isHorizDC Ec Ec Ec
  33. isHorizMinMaxOk a E Ec
  34. doHorizLowPass E e e Ec
  35. doHorizDefFilter Ec Ec e e Ec
  36. do_a_deblock Ec E Ec E
  37. deRing E e e* Ecp
  38. Vertical RKAlgo1 E a a
  39. Horizontal RKAlgo1 a a
  40. Vertical X1# a E E
  41. Horizontal X1# a E E
  42. LinIpolDeinterlace e E E*
  43. CubicIpolDeinterlace a e e*
  44. LinBlendDeinterlace e E E*
  45. MedianDeinterlace# E Ec Ec
  46. TempDeNoiser# E e e Ec
  47. * I do not have a 3DNow! CPU -> it is untested, but no one said it does not work so it seems to work
  48. # more or less selfinvented filters so the exactness is not too meaningful
  49. E = Exact implementation
  50. e = almost exact implementation (slightly different rounding,...)
  51. a = alternative / approximate impl
  52. c = checked against the other implementations (-vo md5)
  53. p = partially optimized, still some work to do
  54. */
  55. /*
  56. TODO:
  57. reduce the time wasted on the mem transfer
  58. unroll stuff if instructions depend too much on the prior one
  59. move YScale thing to the end instead of fixing QP
  60. write a faster and higher quality deblocking filter :)
  61. make the mainloop more flexible (variable number of blocks at once
  62. (the if/else stuff per block is slowing things down)
  63. compare the quality & speed of all filters
  64. split this huge file
  65. optimize c versions
  66. try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks
  67. ...
  68. */
  69. //Changelog: use git log
  70. #include "config.h"
  71. #include "libavutil/avutil.h"
  72. #include "libavutil/avassert.h"
  73. #include <inttypes.h>
  74. #include <stdio.h>
  75. #include <stdlib.h>
  76. #include <string.h>
  77. //#undef HAVE_MMXEXT_INLINE
  78. //#define HAVE_AMD3DNOW_INLINE
  79. //#undef HAVE_MMX_INLINE
  80. //#undef ARCH_X86
  81. //#define DEBUG_BRIGHTNESS
  82. #include "postprocess.h"
  83. #include "postprocess_internal.h"
  84. #include "libavutil/avstring.h"
  85. unsigned postproc_version(void)
  86. {
  87. av_assert0(LIBPOSTPROC_VERSION_MICRO >= 100);
  88. return LIBPOSTPROC_VERSION_INT;
  89. }
  90. const char *postproc_configuration(void)
  91. {
  92. return FFMPEG_CONFIGURATION;
  93. }
  94. const char *postproc_license(void)
  95. {
  96. #define LICENSE_PREFIX "libpostproc license: "
  97. return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
  98. }
  99. #if HAVE_ALTIVEC_H
  100. #include <altivec.h>
  101. #endif
  102. #define GET_MODE_BUFFER_SIZE 500
  103. #define OPTIONS_ARRAY_SIZE 10
  104. #define BLOCK_SIZE 8
  105. #define TEMP_STRIDE 8
  106. //#define NUM_BLOCKS_AT_ONCE 16 //not used yet
  107. #if ARCH_X86 && HAVE_INLINE_ASM
  108. DECLARE_ASM_CONST(8, uint64_t, w05)= 0x0005000500050005LL;
  109. DECLARE_ASM_CONST(8, uint64_t, w04)= 0x0004000400040004LL;
  110. DECLARE_ASM_CONST(8, uint64_t, w20)= 0x0020002000200020LL;
  111. DECLARE_ASM_CONST(8, uint64_t, b00)= 0x0000000000000000LL;
  112. DECLARE_ASM_CONST(8, uint64_t, b01)= 0x0101010101010101LL;
  113. DECLARE_ASM_CONST(8, uint64_t, b02)= 0x0202020202020202LL;
  114. DECLARE_ASM_CONST(8, uint64_t, b08)= 0x0808080808080808LL;
  115. DECLARE_ASM_CONST(8, uint64_t, b80)= 0x8080808080808080LL;
  116. #endif
  117. DECLARE_ASM_CONST(8, int, deringThreshold)= 20;
  118. static const struct PPFilter filters[]=
  119. {
  120. {"hb", "hdeblock", 1, 1, 3, H_DEBLOCK},
  121. {"vb", "vdeblock", 1, 2, 4, V_DEBLOCK},
  122. /* {"hr", "rkhdeblock", 1, 1, 3, H_RK1_FILTER},
  123. {"vr", "rkvdeblock", 1, 2, 4, V_RK1_FILTER},*/
  124. {"h1", "x1hdeblock", 1, 1, 3, H_X1_FILTER},
  125. {"v1", "x1vdeblock", 1, 2, 4, V_X1_FILTER},
  126. {"ha", "ahdeblock", 1, 1, 3, H_A_DEBLOCK},
  127. {"va", "avdeblock", 1, 2, 4, V_A_DEBLOCK},
  128. {"dr", "dering", 1, 5, 6, DERING},
  129. {"al", "autolevels", 0, 1, 2, LEVEL_FIX},
  130. {"lb", "linblenddeint", 1, 1, 4, LINEAR_BLEND_DEINT_FILTER},
  131. {"li", "linipoldeint", 1, 1, 4, LINEAR_IPOL_DEINT_FILTER},
  132. {"ci", "cubicipoldeint", 1, 1, 4, CUBIC_IPOL_DEINT_FILTER},
  133. {"md", "mediandeint", 1, 1, 4, MEDIAN_DEINT_FILTER},
  134. {"fd", "ffmpegdeint", 1, 1, 4, FFMPEG_DEINT_FILTER},
  135. {"l5", "lowpass5", 1, 1, 4, LOWPASS5_DEINT_FILTER},
  136. {"tn", "tmpnoise", 1, 7, 8, TEMP_NOISE_FILTER},
  137. {"fq", "forcequant", 1, 0, 0, FORCE_QUANT},
  138. {"be", "bitexact", 1, 0, 0, BITEXACT},
  139. {NULL, NULL,0,0,0,0} //End Marker
  140. };
  141. static const char *replaceTable[]=
  142. {
  143. "default", "hb:a,vb:a,dr:a",
  144. "de", "hb:a,vb:a,dr:a",
  145. "fast", "h1:a,v1:a,dr:a",
  146. "fa", "h1:a,v1:a,dr:a",
  147. "ac", "ha:a:128:7,va:a,dr:a",
  148. NULL //End Marker
  149. };
  150. #if ARCH_X86 && HAVE_INLINE_ASM
  151. static inline void prefetchnta(void *p)
  152. {
  153. __asm__ volatile( "prefetchnta (%0)\n\t"
  154. : : "r" (p)
  155. );
  156. }
  157. static inline void prefetcht0(void *p)
  158. {
  159. __asm__ volatile( "prefetcht0 (%0)\n\t"
  160. : : "r" (p)
  161. );
  162. }
  163. static inline void prefetcht1(void *p)
  164. {
  165. __asm__ volatile( "prefetcht1 (%0)\n\t"
  166. : : "r" (p)
  167. );
  168. }
  169. static inline void prefetcht2(void *p)
  170. {
  171. __asm__ volatile( "prefetcht2 (%0)\n\t"
  172. : : "r" (p)
  173. );
  174. }
  175. #endif
  176. /* The horizontal functions exist only in C because the MMX
  177. * code is faster with vertical filters and transposing. */
  178. /**
  179. * Check if the given 8x8 Block is mostly "flat"
  180. */
  181. static inline int isHorizDC_C(const uint8_t src[], int stride, const PPContext *c)
  182. {
  183. int numEq= 0;
  184. int y;
  185. const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
  186. const int dcThreshold= dcOffset*2 + 1;
  187. for(y=0; y<BLOCK_SIZE; y++){
  188. if(((unsigned)(src[0] - src[1] + dcOffset)) < dcThreshold) numEq++;
  189. if(((unsigned)(src[1] - src[2] + dcOffset)) < dcThreshold) numEq++;
  190. if(((unsigned)(src[2] - src[3] + dcOffset)) < dcThreshold) numEq++;
  191. if(((unsigned)(src[3] - src[4] + dcOffset)) < dcThreshold) numEq++;
  192. if(((unsigned)(src[4] - src[5] + dcOffset)) < dcThreshold) numEq++;
  193. if(((unsigned)(src[5] - src[6] + dcOffset)) < dcThreshold) numEq++;
  194. if(((unsigned)(src[6] - src[7] + dcOffset)) < dcThreshold) numEq++;
  195. src+= stride;
  196. }
  197. return numEq > c->ppMode.flatnessThreshold;
  198. }
  199. /**
  200. * Check if the middle 8x8 Block in the given 8x16 block is flat
  201. */
  202. static inline int isVertDC_C(const uint8_t src[], int stride, const PPContext *c)
  203. {
  204. int numEq= 0;
  205. int y;
  206. const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
  207. const int dcThreshold= dcOffset*2 + 1;
  208. src+= stride*4; // src points to begin of the 8x8 Block
  209. for(y=0; y<BLOCK_SIZE-1; y++){
  210. if(((unsigned)(src[0] - src[0+stride] + dcOffset)) < dcThreshold) numEq++;
  211. if(((unsigned)(src[1] - src[1+stride] + dcOffset)) < dcThreshold) numEq++;
  212. if(((unsigned)(src[2] - src[2+stride] + dcOffset)) < dcThreshold) numEq++;
  213. if(((unsigned)(src[3] - src[3+stride] + dcOffset)) < dcThreshold) numEq++;
  214. if(((unsigned)(src[4] - src[4+stride] + dcOffset)) < dcThreshold) numEq++;
  215. if(((unsigned)(src[5] - src[5+stride] + dcOffset)) < dcThreshold) numEq++;
  216. if(((unsigned)(src[6] - src[6+stride] + dcOffset)) < dcThreshold) numEq++;
  217. if(((unsigned)(src[7] - src[7+stride] + dcOffset)) < dcThreshold) numEq++;
  218. src+= stride;
  219. }
  220. return numEq > c->ppMode.flatnessThreshold;
  221. }
  222. static inline int isHorizMinMaxOk_C(const uint8_t src[], int stride, int QP)
  223. {
  224. int i;
  225. for(i=0; i<2; i++){
  226. if((unsigned)(src[0] - src[5] + 2*QP) > 4*QP) return 0;
  227. src += stride;
  228. if((unsigned)(src[2] - src[7] + 2*QP) > 4*QP) return 0;
  229. src += stride;
  230. if((unsigned)(src[4] - src[1] + 2*QP) > 4*QP) return 0;
  231. src += stride;
  232. if((unsigned)(src[6] - src[3] + 2*QP) > 4*QP) return 0;
  233. src += stride;
  234. }
  235. return 1;
  236. }
  237. static inline int isVertMinMaxOk_C(const uint8_t src[], int stride, int QP)
  238. {
  239. int x;
  240. src+= stride*4;
  241. for(x=0; x<BLOCK_SIZE; x+=4){
  242. if((unsigned)(src[ x + 0*stride] - src[ x + 5*stride] + 2*QP) > 4*QP) return 0;
  243. if((unsigned)(src[1+x + 2*stride] - src[1+x + 7*stride] + 2*QP) > 4*QP) return 0;
  244. if((unsigned)(src[2+x + 4*stride] - src[2+x + 1*stride] + 2*QP) > 4*QP) return 0;
  245. if((unsigned)(src[3+x + 6*stride] - src[3+x + 3*stride] + 2*QP) > 4*QP) return 0;
  246. }
  247. return 1;
  248. }
  249. static inline int horizClassify_C(const uint8_t src[], int stride, const PPContext *c)
  250. {
  251. if( isHorizDC_C(src, stride, c) ){
  252. if( isHorizMinMaxOk_C(src, stride, c->QP) )
  253. return 1;
  254. else
  255. return 0;
  256. }else{
  257. return 2;
  258. }
  259. }
  260. static inline int vertClassify_C(const uint8_t src[], int stride, const PPContext *c)
  261. {
  262. if( isVertDC_C(src, stride, c) ){
  263. if( isVertMinMaxOk_C(src, stride, c->QP) )
  264. return 1;
  265. else
  266. return 0;
  267. }else{
  268. return 2;
  269. }
  270. }
  271. static inline void doHorizDefFilter_C(uint8_t dst[], int stride, const PPContext *c)
  272. {
  273. int y;
  274. for(y=0; y<BLOCK_SIZE; y++){
  275. const int middleEnergy= 5*(dst[4] - dst[3]) + 2*(dst[2] - dst[5]);
  276. if(FFABS(middleEnergy) < 8*c->QP){
  277. const int q=(dst[3] - dst[4])/2;
  278. const int leftEnergy= 5*(dst[2] - dst[1]) + 2*(dst[0] - dst[3]);
  279. const int rightEnergy= 5*(dst[6] - dst[5]) + 2*(dst[4] - dst[7]);
  280. int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
  281. d= FFMAX(d, 0);
  282. d= (5*d + 32) >> 6;
  283. d*= FFSIGN(-middleEnergy);
  284. if(q>0)
  285. {
  286. d= d<0 ? 0 : d;
  287. d= d>q ? q : d;
  288. }
  289. else
  290. {
  291. d= d>0 ? 0 : d;
  292. d= d<q ? q : d;
  293. }
  294. dst[3]-= d;
  295. dst[4]+= d;
  296. }
  297. dst+= stride;
  298. }
  299. }
  300. /**
  301. * Do a horizontal low pass filter on the 10x8 block (dst points to middle 8x8 Block)
  302. * using the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16 (C version)
  303. */
  304. static inline void doHorizLowPass_C(uint8_t dst[], int stride, const PPContext *c)
  305. {
  306. int y;
  307. for(y=0; y<BLOCK_SIZE; y++){
  308. const int first= FFABS(dst[-1] - dst[0]) < c->QP ? dst[-1] : dst[0];
  309. const int last= FFABS(dst[8] - dst[7]) < c->QP ? dst[8] : dst[7];
  310. int sums[10];
  311. sums[0] = 4*first + dst[0] + dst[1] + dst[2] + 4;
  312. sums[1] = sums[0] - first + dst[3];
  313. sums[2] = sums[1] - first + dst[4];
  314. sums[3] = sums[2] - first + dst[5];
  315. sums[4] = sums[3] - first + dst[6];
  316. sums[5] = sums[4] - dst[0] + dst[7];
  317. sums[6] = sums[5] - dst[1] + last;
  318. sums[7] = sums[6] - dst[2] + last;
  319. sums[8] = sums[7] - dst[3] + last;
  320. sums[9] = sums[8] - dst[4] + last;
  321. dst[0]= (sums[0] + sums[2] + 2*dst[0])>>4;
  322. dst[1]= (sums[1] + sums[3] + 2*dst[1])>>4;
  323. dst[2]= (sums[2] + sums[4] + 2*dst[2])>>4;
  324. dst[3]= (sums[3] + sums[5] + 2*dst[3])>>4;
  325. dst[4]= (sums[4] + sums[6] + 2*dst[4])>>4;
  326. dst[5]= (sums[5] + sums[7] + 2*dst[5])>>4;
  327. dst[6]= (sums[6] + sums[8] + 2*dst[6])>>4;
  328. dst[7]= (sums[7] + sums[9] + 2*dst[7])>>4;
  329. dst+= stride;
  330. }
  331. }
  332. /**
  333. * Experimental Filter 1 (Horizontal)
  334. * will not damage linear gradients
  335. * Flat blocks should look like they were passed through the (1,1,2,2,4,2,2,1,1) 9-Tap filter
  336. * can only smooth blocks at the expected locations (it cannot smooth them if they did move)
  337. * MMX2 version does correct clipping C version does not
  338. * not identical with the vertical one
  339. */
  340. static inline void horizX1Filter(uint8_t *src, int stride, int QP)
  341. {
  342. int y;
  343. static uint64_t lut[256];
  344. if(!lut[255])
  345. {
  346. int i;
  347. for(i=0; i<256; i++)
  348. {
  349. int v= i < 128 ? 2*i : 2*(i-256);
  350. /*
  351. //Simulate 112242211 9-Tap filter
  352. uint64_t a= (v/16) & 0xFF;
  353. uint64_t b= (v/8) & 0xFF;
  354. uint64_t c= (v/4) & 0xFF;
  355. uint64_t d= (3*v/8) & 0xFF;
  356. */
  357. //Simulate piecewise linear interpolation
  358. uint64_t a= (v/16) & 0xFF;
  359. uint64_t b= (v*3/16) & 0xFF;
  360. uint64_t c= (v*5/16) & 0xFF;
  361. uint64_t d= (7*v/16) & 0xFF;
  362. uint64_t A= (0x100 - a)&0xFF;
  363. uint64_t B= (0x100 - b)&0xFF;
  364. uint64_t C= (0x100 - c)&0xFF;
  365. uint64_t D= (0x100 - c)&0xFF;
  366. lut[i] = (a<<56) | (b<<48) | (c<<40) | (d<<32) |
  367. (D<<24) | (C<<16) | (B<<8) | (A);
  368. //lut[i] = (v<<32) | (v<<24);
  369. }
  370. }
  371. for(y=0; y<BLOCK_SIZE; y++){
  372. int a= src[1] - src[2];
  373. int b= src[3] - src[4];
  374. int c= src[5] - src[6];
  375. int d= FFMAX(FFABS(b) - (FFABS(a) + FFABS(c))/2, 0);
  376. if(d < QP){
  377. int v = d * FFSIGN(-b);
  378. src[1] +=v/8;
  379. src[2] +=v/4;
  380. src[3] +=3*v/8;
  381. src[4] -=3*v/8;
  382. src[5] -=v/4;
  383. src[6] -=v/8;
  384. }
  385. src+=stride;
  386. }
  387. }
  388. /**
  389. * accurate deblock filter
  390. */
  391. static av_always_inline void do_a_deblock_C(uint8_t *src, int step,
  392. int stride, const PPContext *c)
  393. {
  394. int y;
  395. const int QP= c->QP;
  396. const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
  397. const int dcThreshold= dcOffset*2 + 1;
  398. //START_TIMER
  399. src+= step*4; // src points to begin of the 8x8 Block
  400. for(y=0; y<8; y++){
  401. int numEq= 0;
  402. if(((unsigned)(src[-1*step] - src[0*step] + dcOffset)) < dcThreshold) numEq++;
  403. if(((unsigned)(src[ 0*step] - src[1*step] + dcOffset)) < dcThreshold) numEq++;
  404. if(((unsigned)(src[ 1*step] - src[2*step] + dcOffset)) < dcThreshold) numEq++;
  405. if(((unsigned)(src[ 2*step] - src[3*step] + dcOffset)) < dcThreshold) numEq++;
  406. if(((unsigned)(src[ 3*step] - src[4*step] + dcOffset)) < dcThreshold) numEq++;
  407. if(((unsigned)(src[ 4*step] - src[5*step] + dcOffset)) < dcThreshold) numEq++;
  408. if(((unsigned)(src[ 5*step] - src[6*step] + dcOffset)) < dcThreshold) numEq++;
  409. if(((unsigned)(src[ 6*step] - src[7*step] + dcOffset)) < dcThreshold) numEq++;
  410. if(((unsigned)(src[ 7*step] - src[8*step] + dcOffset)) < dcThreshold) numEq++;
  411. if(numEq > c->ppMode.flatnessThreshold){
  412. int min, max, x;
  413. if(src[0] > src[step]){
  414. max= src[0];
  415. min= src[step];
  416. }else{
  417. max= src[step];
  418. min= src[0];
  419. }
  420. for(x=2; x<8; x+=2){
  421. if(src[x*step] > src[(x+1)*step]){
  422. if(src[x *step] > max) max= src[ x *step];
  423. if(src[(x+1)*step] < min) min= src[(x+1)*step];
  424. }else{
  425. if(src[(x+1)*step] > max) max= src[(x+1)*step];
  426. if(src[ x *step] < min) min= src[ x *step];
  427. }
  428. }
  429. if(max-min < 2*QP){
  430. const int first= FFABS(src[-1*step] - src[0]) < QP ? src[-1*step] : src[0];
  431. const int last= FFABS(src[8*step] - src[7*step]) < QP ? src[8*step] : src[7*step];
  432. int sums[10];
  433. sums[0] = 4*first + src[0*step] + src[1*step] + src[2*step] + 4;
  434. sums[1] = sums[0] - first + src[3*step];
  435. sums[2] = sums[1] - first + src[4*step];
  436. sums[3] = sums[2] - first + src[5*step];
  437. sums[4] = sums[3] - first + src[6*step];
  438. sums[5] = sums[4] - src[0*step] + src[7*step];
  439. sums[6] = sums[5] - src[1*step] + last;
  440. sums[7] = sums[6] - src[2*step] + last;
  441. sums[8] = sums[7] - src[3*step] + last;
  442. sums[9] = sums[8] - src[4*step] + last;
  443. src[0*step]= (sums[0] + sums[2] + 2*src[0*step])>>4;
  444. src[1*step]= (sums[1] + sums[3] + 2*src[1*step])>>4;
  445. src[2*step]= (sums[2] + sums[4] + 2*src[2*step])>>4;
  446. src[3*step]= (sums[3] + sums[5] + 2*src[3*step])>>4;
  447. src[4*step]= (sums[4] + sums[6] + 2*src[4*step])>>4;
  448. src[5*step]= (sums[5] + sums[7] + 2*src[5*step])>>4;
  449. src[6*step]= (sums[6] + sums[8] + 2*src[6*step])>>4;
  450. src[7*step]= (sums[7] + sums[9] + 2*src[7*step])>>4;
  451. }
  452. }else{
  453. const int middleEnergy= 5*(src[4*step] - src[3*step]) + 2*(src[2*step] - src[5*step]);
  454. if(FFABS(middleEnergy) < 8*QP){
  455. const int q=(src[3*step] - src[4*step])/2;
  456. const int leftEnergy= 5*(src[2*step] - src[1*step]) + 2*(src[0*step] - src[3*step]);
  457. const int rightEnergy= 5*(src[6*step] - src[5*step]) + 2*(src[4*step] - src[7*step]);
  458. int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
  459. d= FFMAX(d, 0);
  460. d= (5*d + 32) >> 6;
  461. d*= FFSIGN(-middleEnergy);
  462. if(q>0){
  463. d= d<0 ? 0 : d;
  464. d= d>q ? q : d;
  465. }else{
  466. d= d>0 ? 0 : d;
  467. d= d<q ? q : d;
  468. }
  469. src[3*step]-= d;
  470. src[4*step]+= d;
  471. }
  472. }
  473. src += stride;
  474. }
  475. /*if(step==16){
  476. STOP_TIMER("step16")
  477. }else{
  478. STOP_TIMER("stepX")
  479. }*/
  480. }
  481. //Note: we have C, MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
  482. //Plain C versions
  483. //we always compile C for testing which needs bitexactness
  484. #define TEMPLATE_PP_C 1
  485. #include "postprocess_template.c"
  486. #if HAVE_ALTIVEC
  487. # define TEMPLATE_PP_ALTIVEC 1
  488. # include "postprocess_altivec_template.c"
  489. # include "postprocess_template.c"
  490. #endif
  491. #if ARCH_X86 && HAVE_INLINE_ASM
  492. # if CONFIG_RUNTIME_CPUDETECT
  493. # define TEMPLATE_PP_MMX 1
  494. # include "postprocess_template.c"
  495. # define TEMPLATE_PP_MMXEXT 1
  496. # include "postprocess_template.c"
  497. # define TEMPLATE_PP_3DNOW 1
  498. # include "postprocess_template.c"
  499. # define TEMPLATE_PP_SSE2 1
  500. # include "postprocess_template.c"
  501. # else
  502. # if HAVE_SSE2_INLINE
  503. # define TEMPLATE_PP_SSE2 1
  504. # include "postprocess_template.c"
  505. # elif HAVE_MMXEXT_INLINE
  506. # define TEMPLATE_PP_MMXEXT 1
  507. # include "postprocess_template.c"
  508. # elif HAVE_AMD3DNOW_INLINE
  509. # define TEMPLATE_PP_3DNOW 1
  510. # include "postprocess_template.c"
  511. # elif HAVE_MMX_INLINE
  512. # define TEMPLATE_PP_MMX 1
  513. # include "postprocess_template.c"
  514. # endif
  515. # endif
  516. #endif
  517. typedef void (*pp_fn)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
  518. const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2);
  519. static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
  520. const QP_STORE_T QPs[], int QPStride, int isColor, pp_mode *vm, pp_context *vc)
  521. {
  522. pp_fn pp = postProcess_C;
  523. PPContext *c= (PPContext *)vc;
  524. PPMode *ppMode= (PPMode *)vm;
  525. c->ppMode= *ppMode; //FIXME
  526. if (!(ppMode->lumMode & BITEXACT)) {
  527. #if CONFIG_RUNTIME_CPUDETECT
  528. #if ARCH_X86 && HAVE_INLINE_ASM
  529. // ordered per speed fastest first
  530. if (c->cpuCaps & AV_CPU_FLAG_SSE2) pp = postProcess_SSE2;
  531. else if (c->cpuCaps & AV_CPU_FLAG_MMXEXT) pp = postProcess_MMX2;
  532. else if (c->cpuCaps & AV_CPU_FLAG_3DNOW) pp = postProcess_3DNow;
  533. else if (c->cpuCaps & AV_CPU_FLAG_MMX) pp = postProcess_MMX;
  534. #elif HAVE_ALTIVEC
  535. if (c->cpuCaps & AV_CPU_FLAG_ALTIVEC) pp = postProcess_altivec;
  536. #endif
  537. #else /* CONFIG_RUNTIME_CPUDETECT */
  538. #if HAVE_SSE2_INLINE
  539. pp = postProcess_SSE2;
  540. #elif HAVE_MMXEXT_INLINE
  541. pp = postProcess_MMX2;
  542. #elif HAVE_AMD3DNOW_INLINE
  543. pp = postProcess_3DNow;
  544. #elif HAVE_MMX_INLINE
  545. pp = postProcess_MMX;
  546. #elif HAVE_ALTIVEC
  547. pp = postProcess_altivec;
  548. #endif
  549. #endif /* !CONFIG_RUNTIME_CPUDETECT */
  550. }
  551. pp(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
  552. }
  553. /* -pp Command line Help
  554. */
  555. const char pp_help[] =
  556. "Available postprocessing filters:\n"
  557. "Filters Options\n"
  558. "short long name short long option Description\n"
  559. "* * a autoq CPU power dependent enabler\n"
  560. " c chrom chrominance filtering enabled\n"
  561. " y nochrom chrominance filtering disabled\n"
  562. " n noluma luma filtering disabled\n"
  563. "hb hdeblock (2 threshold) horizontal deblocking filter\n"
  564. " 1. difference factor: default=32, higher -> more deblocking\n"
  565. " 2. flatness threshold: default=39, lower -> more deblocking\n"
  566. " the h & v deblocking filters share these\n"
  567. " so you can't set different thresholds for h / v\n"
  568. "vb vdeblock (2 threshold) vertical deblocking filter\n"
  569. "ha hadeblock (2 threshold) horizontal deblocking filter\n"
  570. "va vadeblock (2 threshold) vertical deblocking filter\n"
  571. "h1 x1hdeblock experimental h deblock filter 1\n"
  572. "v1 x1vdeblock experimental v deblock filter 1\n"
  573. "dr dering deringing filter\n"
  574. "al autolevels automatic brightness / contrast\n"
  575. " f fullyrange stretch luminance to (0..255)\n"
  576. "lb linblenddeint linear blend deinterlacer\n"
  577. "li linipoldeint linear interpolating deinterlace\n"
  578. "ci cubicipoldeint cubic interpolating deinterlacer\n"
  579. "md mediandeint median deinterlacer\n"
  580. "fd ffmpegdeint ffmpeg deinterlacer\n"
  581. "l5 lowpass5 FIR lowpass deinterlacer\n"
  582. "de default hb:a,vb:a,dr:a\n"
  583. "fa fast h1:a,v1:a,dr:a\n"
  584. "ac ha:a:128:7,va:a,dr:a\n"
  585. "tn tmpnoise (3 threshold) temporal noise reducer\n"
  586. " 1. <= 2. <= 3. larger -> stronger filtering\n"
  587. "fq forceQuant <quantizer> force quantizer\n"
  588. "Usage:\n"
  589. "<filterName>[:<option>[:<option>...]][[,|/][-]<filterName>[:<option>...]]...\n"
  590. "long form example:\n"
  591. "vdeblock:autoq/hdeblock:autoq/linblenddeint default,-vdeblock\n"
  592. "short form example:\n"
  593. "vb:a/hb:a/lb de,-vb\n"
  594. "more examples:\n"
  595. "tn:64:128:256\n"
  596. "\n"
  597. ;
  598. pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality)
  599. {
  600. char temp[GET_MODE_BUFFER_SIZE];
  601. char *p= temp;
  602. static const char filterDelimiters[] = ",/";
  603. static const char optionDelimiters[] = ":";
  604. struct PPMode *ppMode;
  605. char *filterToken;
  606. if (!name) {
  607. av_log(NULL, AV_LOG_ERROR, "pp: Missing argument\n");
  608. return NULL;
  609. }
  610. if (!strcmp(name, "help")) {
  611. const char *p;
  612. for (p = pp_help; strchr(p, '\n'); p = strchr(p, '\n') + 1) {
  613. av_strlcpy(temp, p, FFMIN(sizeof(temp), strchr(p, '\n') - p + 2));
  614. av_log(NULL, AV_LOG_INFO, "%s", temp);
  615. }
  616. return NULL;
  617. }
  618. ppMode= av_malloc(sizeof(PPMode));
  619. ppMode->lumMode= 0;
  620. ppMode->chromMode= 0;
  621. ppMode->maxTmpNoise[0]= 700;
  622. ppMode->maxTmpNoise[1]= 1500;
  623. ppMode->maxTmpNoise[2]= 3000;
  624. ppMode->maxAllowedY= 234;
  625. ppMode->minAllowedY= 16;
  626. ppMode->baseDcDiff= 256/8;
  627. ppMode->flatnessThreshold= 56-16-1;
  628. ppMode->maxClippedThreshold= 0.01;
  629. ppMode->error=0;
  630. memset(temp, 0, GET_MODE_BUFFER_SIZE);
  631. av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE - 1);
  632. av_log(NULL, AV_LOG_DEBUG, "pp: %s\n", name);
  633. for(;;){
  634. char *filterName;
  635. int q= 1000000; //PP_QUALITY_MAX;
  636. int chrom=-1;
  637. int luma=-1;
  638. char *option;
  639. char *options[OPTIONS_ARRAY_SIZE];
  640. int i;
  641. int filterNameOk=0;
  642. int numOfUnknownOptions=0;
  643. int enable=1; //does the user want us to enabled or disabled the filter
  644. filterToken= strtok(p, filterDelimiters);
  645. if(filterToken == NULL) break;
  646. p+= strlen(filterToken) + 1; // p points to next filterToken
  647. filterName= strtok(filterToken, optionDelimiters);
  648. av_log(NULL, AV_LOG_DEBUG, "pp: %s::%s\n", filterToken, filterName);
  649. if(*filterName == '-'){
  650. enable=0;
  651. filterName++;
  652. }
  653. for(;;){ //for all options
  654. option= strtok(NULL, optionDelimiters);
  655. if(option == NULL) break;
  656. av_log(NULL, AV_LOG_DEBUG, "pp: option: %s\n", option);
  657. if(!strcmp("autoq", option) || !strcmp("a", option)) q= quality;
  658. else if(!strcmp("nochrom", option) || !strcmp("y", option)) chrom=0;
  659. else if(!strcmp("chrom", option) || !strcmp("c", option)) chrom=1;
  660. else if(!strcmp("noluma", option) || !strcmp("n", option)) luma=0;
  661. else{
  662. options[numOfUnknownOptions] = option;
  663. numOfUnknownOptions++;
  664. }
  665. if(numOfUnknownOptions >= OPTIONS_ARRAY_SIZE-1) break;
  666. }
  667. options[numOfUnknownOptions] = NULL;
  668. /* replace stuff from the replace Table */
  669. for(i=0; replaceTable[2*i]!=NULL; i++){
  670. if(!strcmp(replaceTable[2*i], filterName)){
  671. int newlen= strlen(replaceTable[2*i + 1]);
  672. int plen;
  673. int spaceLeft;
  674. p--, *p=',';
  675. plen= strlen(p);
  676. spaceLeft= p - temp + plen;
  677. if(spaceLeft + newlen >= GET_MODE_BUFFER_SIZE - 1){
  678. ppMode->error++;
  679. break;
  680. }
  681. memmove(p + newlen, p, plen+1);
  682. memcpy(p, replaceTable[2*i + 1], newlen);
  683. filterNameOk=1;
  684. }
  685. }
  686. for(i=0; filters[i].shortName!=NULL; i++){
  687. if( !strcmp(filters[i].longName, filterName)
  688. || !strcmp(filters[i].shortName, filterName)){
  689. ppMode->lumMode &= ~filters[i].mask;
  690. ppMode->chromMode &= ~filters[i].mask;
  691. filterNameOk=1;
  692. if(!enable) break; // user wants to disable it
  693. if(q >= filters[i].minLumQuality && luma)
  694. ppMode->lumMode|= filters[i].mask;
  695. if(chrom==1 || (chrom==-1 && filters[i].chromDefault))
  696. if(q >= filters[i].minChromQuality)
  697. ppMode->chromMode|= filters[i].mask;
  698. if(filters[i].mask == LEVEL_FIX){
  699. int o;
  700. ppMode->minAllowedY= 16;
  701. ppMode->maxAllowedY= 234;
  702. for(o=0; options[o]!=NULL; o++){
  703. if( !strcmp(options[o],"fullyrange")
  704. ||!strcmp(options[o],"f")){
  705. ppMode->minAllowedY= 0;
  706. ppMode->maxAllowedY= 255;
  707. numOfUnknownOptions--;
  708. }
  709. }
  710. }
  711. else if(filters[i].mask == TEMP_NOISE_FILTER)
  712. {
  713. int o;
  714. int numOfNoises=0;
  715. for(o=0; options[o]!=NULL; o++){
  716. char *tail;
  717. ppMode->maxTmpNoise[numOfNoises]=
  718. strtol(options[o], &tail, 0);
  719. if(tail!=options[o]){
  720. numOfNoises++;
  721. numOfUnknownOptions--;
  722. if(numOfNoises >= 3) break;
  723. }
  724. }
  725. }
  726. else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK
  727. || filters[i].mask == V_A_DEBLOCK || filters[i].mask == H_A_DEBLOCK){
  728. int o;
  729. for(o=0; options[o]!=NULL && o<2; o++){
  730. char *tail;
  731. int val= strtol(options[o], &tail, 0);
  732. if(tail==options[o]) break;
  733. numOfUnknownOptions--;
  734. if(o==0) ppMode->baseDcDiff= val;
  735. else ppMode->flatnessThreshold= val;
  736. }
  737. }
  738. else if(filters[i].mask == FORCE_QUANT){
  739. int o;
  740. ppMode->forcedQuant= 15;
  741. for(o=0; options[o]!=NULL && o<1; o++){
  742. char *tail;
  743. int val= strtol(options[o], &tail, 0);
  744. if(tail==options[o]) break;
  745. numOfUnknownOptions--;
  746. ppMode->forcedQuant= val;
  747. }
  748. }
  749. }
  750. }
  751. if(!filterNameOk) ppMode->error++;
  752. ppMode->error += numOfUnknownOptions;
  753. }
  754. av_log(NULL, AV_LOG_DEBUG, "pp: lumMode=%X, chromMode=%X\n", ppMode->lumMode, ppMode->chromMode);
  755. if(ppMode->error){
  756. av_log(NULL, AV_LOG_ERROR, "%d errors in postprocess string \"%s\"\n", ppMode->error, name);
  757. av_free(ppMode);
  758. return NULL;
  759. }
  760. return ppMode;
  761. }
  762. void pp_free_mode(pp_mode *mode){
  763. av_free(mode);
  764. }
  765. static void reallocAlign(void **p, int alignment, int size){
  766. av_free(*p);
  767. *p= av_mallocz(size);
  768. }
  769. static void reallocBuffers(PPContext *c, int width, int height, int stride, int qpStride){
  770. int mbWidth = (width+15)>>4;
  771. int mbHeight= (height+15)>>4;
  772. int i;
  773. c->stride= stride;
  774. c->qpStride= qpStride;
  775. reallocAlign((void **)&c->tempDst, 8, stride*24+32);
  776. reallocAlign((void **)&c->tempSrc, 8, stride*24);
  777. reallocAlign((void **)&c->tempBlocks, 8, 2*16*8);
  778. reallocAlign((void **)&c->yHistogram, 8, 256*sizeof(uint64_t));
  779. for(i=0; i<256; i++)
  780. c->yHistogram[i]= width*height/64*15/256;
  781. for(i=0; i<3; i++){
  782. //Note: The +17*1024 is just there so I do not have to worry about r/w over the end.
  783. reallocAlign((void **)&c->tempBlurred[i], 8, stride*mbHeight*16 + 17*1024);
  784. reallocAlign((void **)&c->tempBlurredPast[i], 8, 256*((height+7)&(~7))/2 + 17*1024);//FIXME size
  785. }
  786. reallocAlign((void **)&c->deintTemp, 8, 2*width+32);
  787. reallocAlign((void **)&c->nonBQPTable, 8, qpStride*mbHeight*sizeof(QP_STORE_T));
  788. reallocAlign((void **)&c->stdQPTable, 8, qpStride*mbHeight*sizeof(QP_STORE_T));
  789. reallocAlign((void **)&c->forcedQPTable, 8, mbWidth*sizeof(QP_STORE_T));
  790. }
  791. static const char * context_to_name(void * ptr) {
  792. return "postproc";
  793. }
  794. static const AVClass av_codec_context_class = { "Postproc", context_to_name, NULL };
  795. pp_context *pp_get_context(int width, int height, int cpuCaps){
  796. PPContext *c= av_malloc(sizeof(PPContext));
  797. int stride= FFALIGN(width, 16); //assumed / will realloc if needed
  798. int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed
  799. memset(c, 0, sizeof(PPContext));
  800. c->av_class = &av_codec_context_class;
  801. if(cpuCaps&PP_FORMAT){
  802. c->hChromaSubSample= cpuCaps&0x3;
  803. c->vChromaSubSample= (cpuCaps>>4)&0x3;
  804. }else{
  805. c->hChromaSubSample= 1;
  806. c->vChromaSubSample= 1;
  807. }
  808. if (cpuCaps & PP_CPU_CAPS_AUTO) {
  809. c->cpuCaps = av_get_cpu_flags();
  810. } else {
  811. c->cpuCaps = 0;
  812. if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;
  813. if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;
  814. if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;
  815. if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;
  816. }
  817. reallocBuffers(c, width, height, stride, qpStride);
  818. c->frameNum=-1;
  819. return c;
  820. }
  821. void pp_free_context(void *vc){
  822. PPContext *c = (PPContext*)vc;
  823. int i;
  824. for(i=0; i<3; i++) av_free(c->tempBlurred[i]);
  825. for(i=0; i<3; i++) av_free(c->tempBlurredPast[i]);
  826. av_free(c->tempBlocks);
  827. av_free(c->yHistogram);
  828. av_free(c->tempDst);
  829. av_free(c->tempSrc);
  830. av_free(c->deintTemp);
  831. av_free(c->stdQPTable);
  832. av_free(c->nonBQPTable);
  833. av_free(c->forcedQPTable);
  834. memset(c, 0, sizeof(PPContext));
  835. av_free(c);
  836. }
  837. void pp_postprocess(const uint8_t * src[3], const int srcStride[3],
  838. uint8_t * dst[3], const int dstStride[3],
  839. int width, int height,
  840. const QP_STORE_T *QP_store, int QPStride,
  841. pp_mode *vm, void *vc, int pict_type)
  842. {
  843. int mbWidth = (width+15)>>4;
  844. int mbHeight= (height+15)>>4;
  845. PPMode *mode = (PPMode*)vm;
  846. PPContext *c = (PPContext*)vc;
  847. int minStride= FFMAX(FFABS(srcStride[0]), FFABS(dstStride[0]));
  848. int absQPStride = FFABS(QPStride);
  849. // c->stride and c->QPStride are always positive
  850. if(c->stride < minStride || c->qpStride < absQPStride)
  851. reallocBuffers(c, width, height,
  852. FFMAX(minStride, c->stride),
  853. FFMAX(c->qpStride, absQPStride));
  854. if(QP_store==NULL || (mode->lumMode & FORCE_QUANT)){
  855. int i;
  856. QP_store= c->forcedQPTable;
  857. absQPStride = QPStride = 0;
  858. if(mode->lumMode & FORCE_QUANT)
  859. for(i=0; i<mbWidth; i++) c->forcedQPTable[i]= mode->forcedQuant;
  860. else
  861. for(i=0; i<mbWidth; i++) c->forcedQPTable[i]= 1;
  862. }
  863. if(pict_type & PP_PICT_TYPE_QP2){
  864. int i;
  865. const int count= FFMAX(mbHeight * absQPStride, mbWidth);
  866. for(i=0; i<(count>>2); i++){
  867. ((uint32_t*)c->stdQPTable)[i] = (((const uint32_t*)QP_store)[i]>>1) & 0x7F7F7F7F;
  868. }
  869. for(i<<=2; i<count; i++){
  870. c->stdQPTable[i] = QP_store[i]>>1;
  871. }
  872. QP_store= c->stdQPTable;
  873. QPStride= absQPStride;
  874. }
  875. if(0){
  876. int x,y;
  877. for(y=0; y<mbHeight; y++){
  878. for(x=0; x<mbWidth; x++){
  879. av_log(c, AV_LOG_INFO, "%2d ", QP_store[x + y*QPStride]);
  880. }
  881. av_log(c, AV_LOG_INFO, "\n");
  882. }
  883. av_log(c, AV_LOG_INFO, "\n");
  884. }
  885. if((pict_type&7)!=3){
  886. if (QPStride >= 0){
  887. int i;
  888. const int count= FFMAX(mbHeight * QPStride, mbWidth);
  889. for(i=0; i<(count>>2); i++){
  890. ((uint32_t*)c->nonBQPTable)[i] = ((const uint32_t*)QP_store)[i] & 0x3F3F3F3F;
  891. }
  892. for(i<<=2; i<count; i++){
  893. c->nonBQPTable[i] = QP_store[i] & 0x3F;
  894. }
  895. } else {
  896. int i,j;
  897. for(i=0; i<mbHeight; i++) {
  898. for(j=0; j<absQPStride; j++) {
  899. c->nonBQPTable[i*absQPStride+j] = QP_store[i*QPStride+j] & 0x3F;
  900. }
  901. }
  902. }
  903. }
  904. av_log(c, AV_LOG_DEBUG, "using npp filters 0x%X/0x%X\n",
  905. mode->lumMode, mode->chromMode);
  906. postProcess(src[0], srcStride[0], dst[0], dstStride[0],
  907. width, height, QP_store, QPStride, 0, mode, c);
  908. width = (width )>>c->hChromaSubSample;
  909. height = (height)>>c->vChromaSubSample;
  910. if(mode->chromMode){
  911. postProcess(src[1], srcStride[1], dst[1], dstStride[1],
  912. width, height, QP_store, QPStride, 1, mode, c);
  913. postProcess(src[2], srcStride[2], dst[2], dstStride[2],
  914. width, height, QP_store, QPStride, 2, mode, c);
  915. }
  916. else if(srcStride[1] == dstStride[1] && srcStride[2] == dstStride[2]){
  917. linecpy(dst[1], src[1], height, srcStride[1]);
  918. linecpy(dst[2], src[2], height, srcStride[2]);
  919. }else{
  920. int y;
  921. for(y=0; y<height; y++){
  922. memcpy(&(dst[1][y*dstStride[1]]), &(src[1][y*srcStride[1]]), width);
  923. memcpy(&(dst[2][y*dstStride[2]]), &(src[2][y*srcStride[2]]), width);
  924. }
  925. }
  926. }