strFwdTransform.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. //*@@@+++@@@@******************************************************************
  2. //
  3. // Copyright © Microsoft Corp.
  4. // All rights reserved.
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions are met:
  8. //
  9. // • Redistributions of source code must retain the above copyright notice,
  10. // this list of conditions and the following disclaimer.
  11. // • Redistributions in binary form must reproduce the above copyright notice,
  12. // this list of conditions and the following disclaimer in the documentation
  13. // and/or other materials provided with the distribution.
  14. //
  15. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  19. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. // POSSIBILITY OF SUCH DAMAGE.
  26. //
  27. //*@@@---@@@@******************************************************************
  28. #include "strTransform.h"
  29. #include "encode.h"
  30. /** rotation by pi/8 **/
  31. #define ROTATE1(a, b) (b) -= (((a) + 1) >> 1), (a) += (((b) + 1) >> 1) // this works well too
  32. #define ROTATE2(a, b) (b) -= (((a)*3 + 4) >> 3), (a) += (((b)*3 + 4) >> 3) // this works well too
  33. /** local functions **/
  34. static Void fwdOddOdd(PixelI *, PixelI *, PixelI *, PixelI *);
  35. static Void fwdOddOddPre(PixelI *, PixelI *, PixelI *, PixelI *);
  36. static Void fwdOdd(PixelI *, PixelI *, PixelI *, PixelI *);
  37. static Void strDCT2x2alt(PixelI * a, PixelI * b, PixelI * c, PixelI * d);
  38. static Void strHSTenc1(PixelI *, PixelI *);
  39. static Void strHSTenc(PixelI *, PixelI *, PixelI *, PixelI *);
  40. static Void strHSTenc1_edge (PixelI *pa, PixelI *pd);
  41. //static Void scaleDownUp0(PixelI *, PixelI *);
  42. //static Void scaleDownUp1(PixelI *, PixelI *);
  43. //static Void scaleDownUp2(PixelI *, PixelI *);
  44. //#define FOURBUTTERFLY_ENC_ALT(p, i00, i01, i02, i03, i10, i11, i12, i13, \
  45. // i20, i21, i22, i23, i30, i31, i32, i33) \
  46. // strHSTenc(&p[i00], &p[i01], &p[i02], &p[i03]); \
  47. // strHSTenc(&p[i10], &p[i11], &p[i12], &p[i13]); \
  48. // strHSTenc(&p[i20], &p[i21], &p[i22], &p[i23]); \
  49. // strHSTenc(&p[i30], &p[i31], &p[i32], &p[i33]); \
  50. // strHSTenc1(&p[i00], &p[i03]); \
  51. // strHSTenc1(&p[i10], &p[i13]); \
  52. // strHSTenc1(&p[i20], &p[i23]); \
  53. // strHSTenc1(&p[i30], &p[i33])
  54. /** DCT stuff **/
  55. /** data order before DCT **/
  56. /** 0 1 2 3 **/
  57. /** 4 5 6 7 **/
  58. /** 8 9 10 11 **/
  59. /** 12 13 14 15 **/
  60. /** data order after DCT **/
  61. /** 0 8 4 6 **/
  62. /** 2 10 14 12 **/
  63. /** 1 11 15 13 **/
  64. /** 9 3 7 5 **/
  65. /** reordering should be combined with zigzag scan **/
  66. Void strDCT4x4Stage1(PixelI * p)
  67. {
  68. /** butterfly **/
  69. //FOURBUTTERFLY(p, 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
  70. FOURBUTTERFLY_HARDCODED1(p);
  71. /** top left corner, butterfly => butterfly **/
  72. strDCT2x2up(&p[0], &p[1], &p[2], &p[3]);
  73. /** bottom right corner, pi/8 rotation => pi/8 rotation **/
  74. fwdOddOdd(&p[15], &p[14], &p[13], &p[12]);
  75. /** top right corner, butterfly => pi/8 rotation **/
  76. fwdOdd(&p[5], &p[4], &p[7], &p[6]);
  77. /** bottom left corner, pi/8 rotation => butterfly **/
  78. fwdOdd(&p[10], &p[8], &p[11], &p[9]);
  79. }
  80. Void strDCT4x4SecondStage(PixelI * p)
  81. {
  82. /** butterfly **/
  83. FOURBUTTERFLY(p, 0, 192, 48, 240, 64, 128, 112, 176,16, 208, 32, 224, 80, 144, 96, 160);
  84. /** top left corner, butterfly => butterfly **/
  85. strDCT2x2up(&p[0], &p[64], &p[16], &p[80]);
  86. /** bottom right corner, pi/8 rotation => pi/8 rotation **/
  87. fwdOddOdd(&p[160], &p[224], &p[176], &p[240]);
  88. /** top right corner, butterfly => pi/8 rotation **/
  89. fwdOdd(&p[128], &p[192], &p[144], &p[208]);
  90. /** bottom left corner, pi/8 rotation => butterfly **/
  91. fwdOdd(&p[32], &p[48], &p[96], &p[112]);
  92. }
  93. Void strNormalizeEnc(PixelI* p, Bool bChroma)
  94. {
  95. int i;
  96. if (!bChroma) {
  97. //for (i = 0; i < 256; i += 16) {
  98. // p[i] = (p[i] + 1) >> 2;
  99. //}
  100. }
  101. else {
  102. for (i = 0; i < 256; i += 16) {
  103. p[i] >>= 1;
  104. }
  105. }
  106. }
  107. /** 2x2 DCT with pre-scaling - for use on encoder side **/
  108. Void strDCT2x2dnEnc(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  109. {
  110. PixelI a, b, c, d, C, t;
  111. a = (*pa + 0) >> 1;
  112. b = (*pb + 0) >> 1;
  113. C = (*pc + 0) >> 1;
  114. d = (*pd + 0) >> 1;
  115. //PixelI t1, t2;
  116. a += d;
  117. b -= C;
  118. t = ((a - b) >> 1);
  119. c = t - d;
  120. d = t - C;
  121. a -= d;
  122. b += c;
  123. *pa = a;
  124. *pb = b;
  125. *pc = c;
  126. *pd = d;
  127. }
  128. /** pre filter stuff **/
  129. /** 2-point pre for boundaries **/
  130. Void strPre2(PixelI * pa, PixelI * pb)
  131. {
  132. PixelI a, b;
  133. a = *pa;
  134. b = *pb;
  135. /** rotate **/
  136. b -= ((a + 2) >> 2);
  137. a -= ((b + 1) >> 1);
  138. a -= (b >> 5);
  139. a -= (b >> 9);
  140. a -= (b >> 13);
  141. b -= ((a + 2) >> 2);
  142. *pa = a;
  143. *pb = b;
  144. }
  145. Void strPre2x2(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  146. {
  147. PixelI a, b, c, d;
  148. a = *pa;
  149. b = *pb;
  150. c = *pc;
  151. d = *pd;
  152. /** butterflies **/
  153. a += d;
  154. b += c;
  155. d -= (a + 1) >> 1;
  156. c -= (b + 1) >> 1;
  157. /** rotate **/
  158. b -= ((a + 2) >> 2);
  159. a -= ((b + 1) >> 1);
  160. a -= (b >> 5);
  161. a -= (b >> 9);
  162. a -= (b >> 13);
  163. b -= ((a + 2) >> 2);
  164. /** butterflies **/
  165. d += (a + 1) >> 1;
  166. c += (b + 1) >> 1;
  167. a -= d;
  168. b -= c;
  169. *pa = a;
  170. *pb = b;
  171. *pc = c;
  172. *pd = d;
  173. }
  174. /** 4-point pre for boundaries **/
  175. Void strPre4(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  176. {
  177. PixelI a, b, c, d;
  178. a = *pa;
  179. b = *pb;
  180. c = *pc;
  181. d = *pd;
  182. a += d, b += c;
  183. d -= ((a + 1) >> 1), c -= ((b + 1) >> 1);
  184. ROTATE1(c, d);
  185. strHSTenc1_edge(&a, &d); strHSTenc1_edge(&b, &c);
  186. d += ((a + 1) >> 1), c += ((b + 1) >> 1);
  187. a -= d, b -= c;
  188. *pa = a;
  189. *pb = b;
  190. *pc = c;
  191. *pd = d;
  192. }
  193. /*****************************************************************************************
  194. Input data offsets:
  195. (15)(14)|(10+64)(11+64) p0 (15)(14)|(74)(75)
  196. (13)(12)|( 8+64)( 9+64) (13)(12)|(72)(73)
  197. --------+-------------- --------+--------
  198. ( 5)( 4)|( 0+64) (1+64) p1 ( 5)( 4)|(64)(65)
  199. ( 7)( 6)|( 2+64) (3+64) ( 7)( 6)|(66)(67)
  200. *****************************************************************************************/
  201. Void strPre4x4Stage1Split(PixelI *p0, PixelI *p1, Int iOffset)
  202. {
  203. PixelI *p2 = p0 + 72 - iOffset;
  204. PixelI *p3 = p1 + 64 - iOffset;
  205. p0 += 12;
  206. p1 += 4;
  207. /** butterfly & scaling **/
  208. strHSTenc(p0 + 0, p2 + 0, p1 + 0, p3 + 0);
  209. strHSTenc(p0 + 1, p2 + 1, p1 + 1, p3 + 1);
  210. strHSTenc(p0 + 2, p2 + 2, p1 + 2, p3 + 2);
  211. strHSTenc(p0 + 3, p2 + 3, p1 + 3, p3 + 3);
  212. strHSTenc1(p0 + 0, p3 + 0);
  213. strHSTenc1(p0 + 1, p3 + 1);
  214. strHSTenc1(p0 + 2, p3 + 2);
  215. strHSTenc1(p0 + 3, p3 + 3);
  216. /** anti diagonal corners: rotation by pi/8 **/
  217. ROTATE1(p1[2], p1[3]);
  218. ROTATE1(p1[0], p1[1]);
  219. ROTATE1(p2[1], p2[3]);
  220. ROTATE1(p2[0], p2[2]);
  221. /** bottom right corner: pi/8 rotation => pi/8 rotation **/
  222. fwdOddOddPre(p3 + 0, p3 + 1, p3 + 2, p3 + 3);
  223. /** butterfly **/
  224. strDCT2x2dn(p0 + 0, p2 + 0, p1 + 0, p3 + 0);
  225. strDCT2x2dn(p0 + 1, p2 + 1, p1 + 1, p3 + 1);
  226. strDCT2x2dn(p0 + 2, p2 + 2, p1 + 2, p3 + 2);
  227. strDCT2x2dn(p0 + 3, p2 + 3, p1 + 3, p3 + 3);
  228. }
  229. Void strPre4x4Stage1(PixelI* p, Int iOffset)
  230. {
  231. strPre4x4Stage1Split(p, p + 16, iOffset);
  232. }
  233. /*****************************************************************************************
  234. Input data offsets:
  235. (15)(14)|(10+32)(11+32) p0 (15)(14)|(42)(43)
  236. (13)(12)|( 8+32)( 9+32) (13)(12)|(40)(41)
  237. --------+-------------- --------+--------
  238. ( 5)( 4)|( 0+32)( 1+32) p1 ( 5)( 4)|(32)(33)
  239. ( 7)( 6)|( 2+32)( 3+32) ( 7)( 6)|(34)(35)
  240. *****************************************************************************************/
  241. Void strPre4x4Stage2Split(PixelI* p0, PixelI* p1)
  242. {
  243. /** butterfly **/
  244. strHSTenc(p0 - 96, p0 + 96, p1 - 112, p1 + 80);
  245. strHSTenc(p0 - 32, p0 + 32, p1 - 48, p1 + 16);
  246. strHSTenc(p0 - 80, p0 + 112, p1 - 128, p1 + 64);
  247. strHSTenc(p0 - 16, p0 + 48, p1 - 64, p1 + 0);
  248. strHSTenc1(p0 - 96, p1 + 80);
  249. strHSTenc1(p0 - 32, p1 + 16);
  250. strHSTenc1(p0 - 80, p1 + 64);
  251. strHSTenc1(p0 - 16, p1 + 0);
  252. /** anti diagonal corners: rotation **/
  253. ROTATE1(p1[-48], p1[-112]);
  254. ROTATE1(p1[-64], p1[-128]);
  255. ROTATE1(p0[112], p0[ 96]);
  256. ROTATE1(p0[ 48], p0[ 32]);
  257. /** bottom right corner: pi/8 rotation => pi/8 rotation **/
  258. fwdOddOddPre(p1 + 0, p1 + 64, p1 + 16, p1 + 80);
  259. /** butterfly **/
  260. strDCT2x2dn(p0 - 96, p1 - 112, p0 + 96, p1 + 80);
  261. strDCT2x2dn(p0 - 32, p1 - 48, p0 + 32, p1 + 16);
  262. strDCT2x2dn(p0 - 80, p1 - 128, p0 + 112, p1 + 64);
  263. strDCT2x2dn(p0 - 16, p1 - 64, p0 + 48, p1 + 0);
  264. }
  265. /**
  266. Hadamard+Scale transform
  267. for some strange reason, breaking up the function into two blocks, strHSTenc1 and strHSTenc
  268. seems to work faster
  269. **/
  270. static Void strHSTenc(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  271. {
  272. /** different realization : does rescaling as well! **/
  273. PixelI a, b, c, d;
  274. a = *pa;
  275. b = *pb;
  276. d = *pc;
  277. c = *pd;
  278. a += c;
  279. b -= d;
  280. c = ((a - b) >> 1) - c;
  281. d += (b >> 1);
  282. b += c;
  283. a -= (d * 3 + 4) >> 3;
  284. *pa = a;
  285. *pb = b;
  286. *pc = c;
  287. *pd = d;
  288. }
  289. static Void strHSTenc1(PixelI *pa, PixelI *pd)
  290. {
  291. /** different realization : does rescaling as well! **/
  292. PixelI a, d;
  293. a = *pa;
  294. d = *pd;
  295. d -= (a >> 7);
  296. d += (a >> 10);
  297. //a -= (d * 3 + 4) >> 3;
  298. d -= (a * 3 + 0) >> 4;
  299. a -= (d * 3 + 0) >> 3;
  300. d = (a >> 1) - d;
  301. a -= d;
  302. *pa = a;
  303. *pd = d;
  304. }
  305. static Void strHSTenc1_edge (PixelI *pa, PixelI *pd)
  306. {
  307. /** different realizion as compared to scaling operator for 2D case **/
  308. PixelI a, d;
  309. a = *pa;
  310. d = -(*pd); // Negative sign needed here for 1D scaling case to ensure correct scaling.
  311. a -= d;
  312. d += (a >> 1);
  313. a -= (d * 3 + 4) >> 3;
  314. // End new operations
  315. //Scaling modification of adding 7/1024 in two steps (without multiplication by 7).
  316. d -= (a >> 7);
  317. d += (a >> 10);
  318. d -= (a * 3 + 0) >> 4;
  319. a -= (d * 3 + 0) >> 3;
  320. d = (a >> 1) - d;
  321. a -= d;
  322. *pa = a;
  323. *pd = d;
  324. }
  325. /** Kron(Rotate(pi/8), Rotate(pi/8)) **/\
  326. static Void fwdOddOdd(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  327. {
  328. PixelI a, b, c, d, t1, t2;
  329. a = *pa;
  330. b = -*pb;
  331. c = -*pc;
  332. d = *pd;
  333. /** butterflies **/
  334. d += a;
  335. c -= b;
  336. a -= (t1 = d >> 1);
  337. b += (t2 = c >> 1);
  338. /** rotate pi/4 **/
  339. a += (b * 3 + 4) >> 3;
  340. b -= (a * 3 + 3) >> 2;
  341. a += (b * 3 + 3) >> 3;
  342. /** butterflies **/
  343. b -= t2;
  344. a += t1;
  345. c += b;
  346. d -= a;
  347. *pa = a;
  348. *pb = b;
  349. *pc = c;
  350. *pd = d;
  351. }
  352. /** Kron(Rotate(pi/8), Rotate(pi/8)) **/
  353. static Void fwdOddOddPre(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  354. {
  355. PixelI a, b, c, d, t1, t2;
  356. a = *pa;
  357. b = *pb;
  358. c = *pc;
  359. d = *pd;
  360. /** butterflies **/
  361. d += a;
  362. c -= b;
  363. a -= (t1 = d >> 1);
  364. b += (t2 = c >> 1);
  365. /** rotate pi/4 **/
  366. a += (b * 3 + 4) >> 3;
  367. b -= (a * 3 + 2) >> 2;
  368. a += (b * 3 + 6) >> 3;
  369. /** butterflies **/
  370. b -= t2;
  371. a += t1;
  372. c += b;
  373. d -= a;
  374. *pa = a;
  375. *pb = b;
  376. *pc = c;
  377. *pd = d;
  378. }
  379. /** Kron(Rotate(pi/8), [1 1; 1 -1]/sqrt(2)) **/
  380. /** [a b c d] => [D C A B] **/
  381. Void fwdOdd(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
  382. {
  383. PixelI a, b, c, d;
  384. a = *pa;
  385. b = *pb;
  386. c = *pc;
  387. d = *pd;
  388. /** butterflies **/
  389. b -= c;
  390. a += d;
  391. c += (b + 1) >> 1;
  392. d = ((a + 1) >> 1) - d;
  393. /** rotate pi/8 **/
  394. ROTATE2(a, b);
  395. ROTATE2(c, d);
  396. /** butterflies **/
  397. d += (b) >> 1;
  398. c -= (a + 1) >> 1;
  399. b -= d;
  400. a += c;
  401. *pa = a;
  402. *pb = b;
  403. *pc = c;
  404. *pd = d;
  405. }
  406. /*************************************************************************
  407. Top-level function to tranform possible part of a macroblock
  408. *************************************************************************/
  409. Void transformMacroblock(CWMImageStrCodec * pSC)
  410. {
  411. OVERLAP olOverlap = pSC->WMISCP.olOverlap;
  412. COLORFORMAT cfColorFormat = pSC->m_param.cfColorFormat;
  413. Bool left = (pSC->cColumn == 0), right = (pSC->cColumn == pSC->cmbWidth);
  414. Bool top = (pSC->cRow == 0), bottom = (pSC->cRow == pSC->cmbHeight);
  415. Bool leftORright = (left || right), topORbottom = (top || bottom);
  416. Bool topORleft = (left || top);// rightORbottom = (right || bottom);
  417. Bool leftAdjacentColumn = (pSC->cColumn == 1), rightAdjacentColumn = (pSC->cColumn == pSC->cmbWidth - 1);
  418. // Bool topAdjacentRow = (pSC->cRow == 1), bottomAdjacentRow = (pSC->cRow == pSC->cmbHeight - 1);
  419. PixelI * p = NULL;// * pt = NULL;
  420. Int i, j;
  421. Int iNumChromaFullPlanes = (Int)((YUV_420 == cfColorFormat || YUV_422 == cfColorFormat) ?
  422. 1 : pSC->m_param.cNumChannels);
  423. #define mbX pSC->mbX
  424. #define mbY pSC->mbY
  425. #define tileX pSC->tileX
  426. #define tileY pSC->tileY
  427. #define bVertTileBoundary pSC->bVertTileBoundary
  428. #define bHoriTileBoundary pSC->bHoriTileBoundary
  429. #define bOneMBLeftVertTB pSC->bOneMBLeftVertTB
  430. #define bOneMBRightVertTB pSC->bOneMBRightVertTB
  431. #define iPredBefore pSC->iPredBefore
  432. #define iPredAfter pSC->iPredAfter
  433. if (pSC->WMISCP.bUseHardTileBoundaries) {
  434. //Add tile location information
  435. if (pSC->cColumn == 0) {
  436. bVertTileBoundary = FALSE;
  437. tileY = 0;
  438. }
  439. bOneMBLeftVertTB = bOneMBRightVertTB = FALSE;
  440. if(tileY > 0 && tileY <= pSC->WMISCP.cNumOfSliceMinus1H && (pSC->cColumn - 1) == pSC->WMISCP.uiTileY[tileY])
  441. bOneMBRightVertTB = TRUE;
  442. if(tileY < pSC->WMISCP.cNumOfSliceMinus1H && pSC->cColumn == pSC->WMISCP.uiTileY[tileY + 1]) {
  443. bVertTileBoundary = TRUE;
  444. tileY++;
  445. }
  446. else
  447. bVertTileBoundary = FALSE;
  448. if(tileY < pSC->WMISCP.cNumOfSliceMinus1H && (pSC->cColumn + 1) == pSC->WMISCP.uiTileY[tileY + 1])
  449. bOneMBLeftVertTB = TRUE;
  450. if (pSC->cRow == 0) {
  451. bHoriTileBoundary = FALSE;
  452. tileX = 0;
  453. }
  454. else if(mbY != pSC->cRow && tileX < pSC->WMISCP.cNumOfSliceMinus1V && pSC->cRow == pSC->WMISCP.uiTileX[tileX + 1]) {
  455. bHoriTileBoundary = TRUE;
  456. tileX++;
  457. }
  458. else if(mbY != pSC->cRow)
  459. bHoriTileBoundary = FALSE;
  460. }
  461. else {
  462. bVertTileBoundary = FALSE;
  463. bHoriTileBoundary = FALSE;
  464. bOneMBLeftVertTB = FALSE;
  465. bOneMBRightVertTB = FALSE;
  466. }
  467. mbX = pSC->cColumn, mbY = pSC->cRow;
  468. //================================================================
  469. // 400_Y, 444_YUV
  470. for(i = 0; i < iNumChromaFullPlanes; ++i)
  471. {
  472. PixelI* const p0 = pSC->p0MBbuffer[i];//(0 == i ? pSC->pY0 : (1 == i ? pSC->pU0 : pSC->pV0));
  473. PixelI* const p1 = pSC->p1MBbuffer[i];//(0 == i ? pSC->pY1 : (1 == i ? pSC->pU1 : pSC->pV1));
  474. //================================
  475. // first level overlap
  476. if(OL_NONE != olOverlap)
  477. {
  478. /* Corner operations */
  479. if ((top || bHoriTileBoundary) && (left || bVertTileBoundary))
  480. strPre4(p1 + 0, p1 + 1, p1 + 2, p1 + 3);
  481. if ((top || bHoriTileBoundary) && (right || bVertTileBoundary))
  482. strPre4(p1 - 59, p1 - 60, p1 - 57, p1 - 58);
  483. if ((bottom || bHoriTileBoundary) && (left || bVertTileBoundary))
  484. strPre4(p0 + 48 + 10, p0 + 48 + 11, p0 + 48 + 8, p0 + 48 + 9);
  485. if ((bottom || bHoriTileBoundary) && (right || bVertTileBoundary))
  486. strPre4(p0 - 1, p0 - 2, p0 - 3, p0 - 4);
  487. if(!right && !bottom)
  488. {
  489. if (top || bHoriTileBoundary)
  490. {
  491. for (j = ((left || bVertTileBoundary) ? 0 : -64); j < 192; j += 64)
  492. {
  493. p = p1 + j;
  494. strPre4(p + 5, p + 4, p + 64, p + 65);
  495. strPre4(p + 7, p + 6, p + 66, p + 67);
  496. p = NULL;
  497. }
  498. }
  499. else
  500. {
  501. for (j = ((left || bVertTileBoundary) ? 0 : -64); j < 192; j += 64)
  502. {
  503. strPre4x4Stage1Split(p0 + 48 + j, p1 + j, 0);
  504. }
  505. }
  506. if (left || bVertTileBoundary)
  507. {
  508. if (!top && !bHoriTileBoundary)
  509. {
  510. strPre4(p0 + 58, p0 + 56, p1 + 0, p1 + 2);
  511. strPre4(p0 + 59, p0 + 57, p1 + 1, p1 + 3);
  512. }
  513. for (j = -64; j < -16; j += 16)
  514. {
  515. p = p1 + j;
  516. strPre4(p + 74, p + 72, p + 80, p + 82);
  517. strPre4(p + 75, p + 73, p + 81, p + 83);
  518. p = NULL;
  519. }
  520. }
  521. else
  522. {
  523. for (j = -64; j < -16; j += 16)
  524. {
  525. strPre4x4Stage1(p1 + j, 0);
  526. }
  527. }
  528. strPre4x4Stage1(p1 + 0, 0);
  529. strPre4x4Stage1(p1 + 16, 0);
  530. strPre4x4Stage1(p1 + 32, 0);
  531. strPre4x4Stage1(p1 + 64, 0);
  532. strPre4x4Stage1(p1 + 80, 0);
  533. strPre4x4Stage1(p1 + 96, 0);
  534. strPre4x4Stage1(p1 + 128, 0);
  535. strPre4x4Stage1(p1 + 144, 0);
  536. strPre4x4Stage1(p1 + 160, 0);
  537. }
  538. if (bottom || bHoriTileBoundary)
  539. {
  540. for (j = ((left || bVertTileBoundary) ? 48 : -16); j < (right ? -16 : 240); j += 64)
  541. {
  542. p = p0 + j;
  543. strPre4(p + 15, p + 14, p + 74, p + 75);
  544. strPre4(p + 13, p + 12, p + 72, p + 73);
  545. p = NULL;
  546. }
  547. }
  548. if ((right || bVertTileBoundary) && !bottom)
  549. {
  550. if (!top && !bHoriTileBoundary)
  551. {
  552. strPre4(p0 - 1, p0 - 3, p1 - 59, p1 - 57);
  553. strPre4(p0 - 2, p0 - 4, p1 - 60, p1 - 58);
  554. }
  555. for (j = -64; j < -16; j += 16)
  556. {
  557. p = p1 + j;
  558. strPre4(p + 15, p + 13, p + 21, p + 23);
  559. strPre4(p + 14, p + 12, p + 20, p + 22);
  560. p = NULL;
  561. }
  562. }
  563. }
  564. //================================
  565. // first level transform
  566. if (!top)
  567. {
  568. for (j = (left ? 48 : -16); j < (right ? 48 : 240); j += 64)
  569. {
  570. strDCT4x4Stage1(p0 + j);
  571. }
  572. }
  573. if (!bottom)
  574. {
  575. for (j = (left ? 0 : -64); j < (right ? 0 : 192); j += 64)
  576. {
  577. strDCT4x4Stage1(p1 + j + 0);
  578. strDCT4x4Stage1(p1 + j + 16);
  579. strDCT4x4Stage1(p1 + j + 32);
  580. }
  581. }
  582. //================================
  583. // second level overlap
  584. if (OL_TWO == olOverlap)
  585. {
  586. /* Corner operations */
  587. if ((top || bHoriTileBoundary) && (left || bVertTileBoundary))
  588. strPre4(p1 + 0, p1 + 64, p1 + 0 + 16, p1 + 64 + 16);
  589. if ((top || bHoriTileBoundary) && (right || bVertTileBoundary))
  590. strPre4(p1 - 128, p1 - 64, p1 - 128 + 16, p1 - 64 + 16);
  591. if ((bottom || bHoriTileBoundary) && (left || bVertTileBoundary))
  592. strPre4(p0 + 32, p0 + 96, p0 + 32 + 16, p0 + 96 + 16);
  593. if ((bottom || bHoriTileBoundary) && (right || bVertTileBoundary))
  594. strPre4(p0 - 96, p0 - 32, p0 - 96 + 16, p0 - 32 + 16);
  595. if ((leftORright || bVertTileBoundary) && (!topORbottom && !bHoriTileBoundary))
  596. {
  597. if (left || bVertTileBoundary) {
  598. j = 0;
  599. strPre4(p0 + j + 32, p0 + j + 48, p1 + j + 0, p1 + j + 16);
  600. strPre4(p0 + j + 96, p0 + j + 112, p1 + j + 64, p1 + j + 80);
  601. }
  602. if (right || bVertTileBoundary) {
  603. j = -128;
  604. strPre4(p0 + j + 32, p0 + j + 48, p1 + j + 0, p1 + j + 16);
  605. strPre4(p0 + j + 96, p0 + j + 112, p1 + j + 64, p1 + j + 80);
  606. }
  607. }
  608. if (!leftORright && !bVertTileBoundary)
  609. {
  610. if (topORbottom || bHoriTileBoundary)
  611. {
  612. if (top || bHoriTileBoundary) {
  613. p = p1;
  614. strPre4(p - 128, p - 64, p + 0, p + 64);
  615. strPre4(p - 112, p - 48, p + 16, p + 80);
  616. p = NULL;
  617. }
  618. if (bottom || bHoriTileBoundary) {
  619. p = p0 + 32;
  620. strPre4(p - 128, p - 64, p + 0, p + 64);
  621. strPre4(p - 112, p - 48, p + 16, p + 80);
  622. p = NULL;
  623. }
  624. }
  625. else
  626. {
  627. strPre4x4Stage2Split(p0, p1);
  628. }
  629. }
  630. }
  631. //================================
  632. // second level transform
  633. if (!topORleft){
  634. if (pSC->m_param.bScaledArith) {
  635. strNormalizeEnc(p0 - 256, (i != 0));
  636. }
  637. strDCT4x4SecondStage(p0 - 256);
  638. }
  639. }
  640. //================================================================
  641. // 420_UV
  642. for(i = 0; i < (YUV_420 == cfColorFormat? 2 : 0); ++i)
  643. {
  644. PixelI* const p0 = pSC->p0MBbuffer[1 + i];//(0 == i ? pSC->pU0 : pSC->pV0);
  645. PixelI* const p1 = pSC->p1MBbuffer[1 + i];//(0 == i ? pSC->pU1 : pSC->pV1);
  646. //================================
  647. // first level overlap (420_UV)
  648. if (OL_NONE != olOverlap)
  649. {
  650. /* Corner operations */
  651. if ((top || bHoriTileBoundary) && (left || bVertTileBoundary))
  652. strPre4(p1 + 0, p1 + 1, p1 + 2, p1 + 3);
  653. if ((top || bHoriTileBoundary) && (right || bVertTileBoundary))
  654. strPre4(p1 - 27, p1 - 28, p1 - 25, p1 - 26);
  655. if ((bottom || bHoriTileBoundary) && (left || bVertTileBoundary))
  656. strPre4(p0 + 16 + 10, p0 + 16 + 11, p0 + 16 + 8, p0 + 16 + 9);
  657. if ((bottom || bHoriTileBoundary) && (right || bVertTileBoundary))
  658. strPre4(p0 - 1, p0 - 2, p0 - 3, p0 - 4);
  659. if(!right && !bottom)
  660. {
  661. if (top || bHoriTileBoundary)
  662. {
  663. for (j = ((left || bVertTileBoundary) ? 0 : -32); j < 32; j += 32)
  664. {
  665. p = p1 + j;
  666. strPre4(p + 5, p + 4, p + 32, p + 33);
  667. strPre4(p + 7, p + 6, p + 34, p + 35);
  668. p = NULL;
  669. }
  670. }
  671. else
  672. {
  673. for (j = ((left || bVertTileBoundary) ? 0: -32); j < 32; j += 32)
  674. {
  675. strPre4x4Stage1Split(p0 + 16 + j, p1 + j, 32);
  676. }
  677. }
  678. if (left || bVertTileBoundary)
  679. {
  680. if (!top && !bHoriTileBoundary)
  681. {
  682. strPre4(p0 + 26, p0 + 24, p1 + 0, p1 + 2);
  683. strPre4(p0 + 27, p0 + 25, p1 + 1, p1 + 3);
  684. }
  685. strPre4(p1 + 10, p1 + 8, p1 + 16, p1 + 18);
  686. strPre4(p1 + 11, p1 + 9, p1 + 17, p1 + 19);
  687. }
  688. else if (!bVertTileBoundary)
  689. {
  690. strPre4x4Stage1(p1 - 32, 32);
  691. }
  692. strPre4x4Stage1(p1, 32);
  693. }
  694. if (bottom || bHoriTileBoundary)
  695. {
  696. for (j = ((left || bVertTileBoundary) ? 16: -16); j < (right ? -16: 32); j += 32)
  697. {
  698. p = p0 + j;
  699. strPre4(p + 15, p + 14, p + 42, p + 43);
  700. strPre4(p + 13, p + 12, p + 40, p + 41);
  701. p = NULL;
  702. }
  703. }
  704. if ((right || bVertTileBoundary) && !bottom)
  705. {
  706. if (!top && !bHoriTileBoundary)
  707. {
  708. strPre4(p0 - 1, p0 - 3, p1 - 27, p1 - 25);
  709. strPre4(p0 - 2, p0 - 4, p1 - 28, p1 - 26);
  710. }
  711. strPre4(p1 - 17, p1 - 19, p1 - 11, p1 - 9);
  712. strPre4(p1 - 18, p1 - 20, p1 - 12, p1 - 10);
  713. }
  714. }
  715. //================================
  716. // first level transform (420_UV)
  717. if (!top)
  718. {
  719. for (j = (left ? 16 : -16); j < (right ? 16 : 48); j += 32)
  720. {
  721. strDCT4x4Stage1(p0 + j);
  722. }
  723. }
  724. if (!bottom)
  725. {
  726. for (j = (left ? 0 : -32); j < (right ? 0 : 32); j += 32)
  727. {
  728. strDCT4x4Stage1(p1 + j);
  729. }
  730. }
  731. //================================
  732. // second level overlap (420_UV)
  733. if (OL_TWO == olOverlap)
  734. {
  735. if ((leftAdjacentColumn || bOneMBRightVertTB) && (top || bHoriTileBoundary))
  736. COMPUTE_CORNER_PRED_DIFF(p1 - 64 + 0, *(p1 - 64 + 32));
  737. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (top || bHoriTileBoundary))
  738. iPredBefore[i][0] = *(p1 + 0);
  739. if ((right || bVertTileBoundary) && (top || bHoriTileBoundary))
  740. COMPUTE_CORNER_PRED_DIFF(p1 - 64 + 32, iPredBefore[i][0]);
  741. if ((leftAdjacentColumn || bOneMBRightVertTB) && (bottom || bHoriTileBoundary))
  742. COMPUTE_CORNER_PRED_DIFF(p0 - 64 + 16, *(p0 - 64 + 48));
  743. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (bottom || bHoriTileBoundary))
  744. iPredBefore[i][1] = *(p0 + 16);
  745. if ((right || bVertTileBoundary) && (bottom || bHoriTileBoundary))
  746. COMPUTE_CORNER_PRED_DIFF(p0 - 64 + 48, iPredBefore[i][1]);
  747. if ((leftORright || bVertTileBoundary) && !topORbottom && !bHoriTileBoundary)
  748. {
  749. if (left || bVertTileBoundary)
  750. strPre2(p0 + 0 + 16, p1 + 0);
  751. if (right || bVertTileBoundary)
  752. strPre2(p0 + -32 + 16, p1 + -32);
  753. }
  754. if (!leftORright)
  755. {
  756. if ((topORbottom || bHoriTileBoundary) && !bVertTileBoundary)
  757. {
  758. if (top || bHoriTileBoundary)
  759. strPre2(p1 - 32, p1);
  760. if (bottom || bHoriTileBoundary)
  761. strPre2(p0 + 16 - 32, p0 + 16);
  762. }
  763. else if (!topORbottom && !bHoriTileBoundary && !bVertTileBoundary)
  764. strPre2x2(p0 - 16, p0 + 16, p1 - 32, p1);
  765. }
  766. if ((leftAdjacentColumn || bOneMBRightVertTB) && (top || bHoriTileBoundary))
  767. COMPUTE_CORNER_PRED_ADD(p1 - 64 + 0, *(p1 - 64 + 32));
  768. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (top || bHoriTileBoundary))
  769. iPredAfter[i][0] = *(p1 + 0);
  770. if ((right || bVertTileBoundary) && (top || bHoriTileBoundary))
  771. COMPUTE_CORNER_PRED_ADD(p1 - 64 + 32, iPredAfter[i][0]);
  772. if ((leftAdjacentColumn || bOneMBRightVertTB) && (bottom || bHoriTileBoundary))
  773. COMPUTE_CORNER_PRED_ADD(p0 - 64 + 16, *(p0 - 64 + 48));
  774. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (bottom || bHoriTileBoundary))
  775. iPredAfter[i][1] = *(p0 + 16);
  776. if ((right || bVertTileBoundary) && (bottom || bHoriTileBoundary))
  777. COMPUTE_CORNER_PRED_ADD(p0 - 64 + 48, iPredAfter[i][1]);
  778. }
  779. //================================
  780. // second level transform (420_UV)
  781. if (!topORleft)
  782. {
  783. if (!pSC->m_param.bScaledArith) {
  784. strDCT2x2dn(p0 - 64, p0 - 32, p0 - 48, p0 - 16);
  785. }
  786. else {
  787. strDCT2x2dnEnc(p0 - 64, p0 - 32, p0 - 48, p0 - 16);
  788. }
  789. }
  790. }
  791. //================================================================
  792. // 422_UV
  793. for(i = 0; i < (YUV_422 == cfColorFormat? 2 : 0); ++i)
  794. {
  795. PixelI* const p0 = pSC->p0MBbuffer[1 + i];//(0 == i ? pSC->pU0 : pSC->pV0);
  796. PixelI* const p1 = pSC->p1MBbuffer[1 + i];//(0 == i ? pSC->pU1 : pSC->pV1);
  797. //================================
  798. // first level overlap (422_UV)
  799. if (OL_NONE != olOverlap)
  800. {
  801. /* Corner operations */
  802. if ((top || bHoriTileBoundary) && (left || bVertTileBoundary))
  803. strPre4(p1 + 0, p1 + 1, p1 + 2, p1 + 3);
  804. if ((top || bHoriTileBoundary) && (right || bVertTileBoundary))
  805. strPre4(p1 - 59, p1 - 60, p1 - 57, p1 - 58);
  806. if ((bottom || bHoriTileBoundary) && (left || bVertTileBoundary))
  807. strPre4(p0 + 48 + 10, p0 + 48 + 11, p0 + 48 + 8, p0 + 48 + 9);
  808. if ((bottom || bHoriTileBoundary) && (right || bVertTileBoundary))
  809. strPre4(p0 - 1, p0 - 2, p0 - 3, p0 - 4);
  810. if(!right && !bottom)
  811. {
  812. if (top || bHoriTileBoundary)
  813. {
  814. for (j = ((left || bVertTileBoundary) ? 0 : -64); j < 64; j += 64)
  815. {
  816. p = p1 + j;
  817. strPre4(p + 5, p + 4, p + 64, p + 65);
  818. strPre4(p + 7, p + 6, p + 66, p + 67);
  819. p = NULL;
  820. }
  821. }
  822. else
  823. {
  824. for (j = ((left || bVertTileBoundary) ? 0: -64); j < 64; j += 64)
  825. {
  826. strPre4x4Stage1Split(p0 + 48 + j, p1 + j, 0);
  827. }
  828. }
  829. if (left || bVertTileBoundary)
  830. {
  831. if (!top && !bHoriTileBoundary)
  832. {
  833. strPre4(p0 + 58, p0 + 56, p1 + 0, p1 + 2);
  834. strPre4(p0 + 59, p0 + 57, p1 + 1, p1 + 3);
  835. }
  836. for (j = 0; j < 48; j += 16)
  837. {
  838. p = p1 + j;
  839. strPre4(p + 10, p + 8, p + 16, p + 18);
  840. strPre4(p + 11, p + 9, p + 17, p + 19);
  841. p = NULL;
  842. }
  843. }
  844. else if (!bVertTileBoundary)
  845. {
  846. for (j = -64; j < -16; j += 16)
  847. {
  848. strPre4x4Stage1(p1 + j, 0);
  849. }
  850. }
  851. strPre4x4Stage1(p1 + 0, 0);
  852. strPre4x4Stage1(p1 + 16, 0);
  853. strPre4x4Stage1(p1 + 32, 0);
  854. }
  855. if (bottom || bHoriTileBoundary)
  856. {
  857. for (j = ((left || bVertTileBoundary) ? 48: -16); j < (right ? -16: 112); j += 64)
  858. {
  859. p = p0 + j;
  860. strPre4(p + 15, p + 14, p + 74, p + 75);
  861. strPre4(p + 13, p + 12, p + 72, p + 73);
  862. p = NULL;
  863. }
  864. }
  865. if ((right || bVertTileBoundary) && !bottom)
  866. {
  867. if (!top && !bHoriTileBoundary)
  868. {
  869. strPre4(p0 - 1, p0 - 3, p1 - 59, p1 - 57);
  870. strPre4(p0 - 2, p0 - 4, p1 - 60, p1 - 58);
  871. }
  872. for (j = -64; j < -16; j += 16)
  873. {
  874. p = p1 + j;
  875. strPre4(p + 15, p + 13, p + 21, p + 23);
  876. strPre4(p + 14, p + 12, p + 20, p + 22);
  877. p = NULL;
  878. }
  879. }
  880. }
  881. //================================
  882. // first level transform (422_UV)
  883. if (!top)
  884. {
  885. for (j = (left ? 48 : -16); j < (right ? 48 : 112); j += 64)
  886. {
  887. strDCT4x4Stage1(p0 + j);
  888. }
  889. }
  890. if (!bottom)
  891. {
  892. for (j = (left ? 0 : -64); j < (right ? 0 : 64); j += 64)
  893. {
  894. strDCT4x4Stage1(p1 + j + 0);
  895. strDCT4x4Stage1(p1 + j + 16);
  896. strDCT4x4Stage1(p1 + j + 32);
  897. }
  898. }
  899. //================================
  900. // second level overlap (422_UV)
  901. if (OL_TWO == olOverlap)
  902. {
  903. if ((leftAdjacentColumn || bOneMBRightVertTB) && (top || bHoriTileBoundary))
  904. COMPUTE_CORNER_PRED_DIFF(p1 - 128 + 0, *(p1 - 128 + 64));
  905. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (top || bHoriTileBoundary))
  906. iPredBefore[i][0] = *(p1 + 0);
  907. if ((right || bVertTileBoundary) && (top || bHoriTileBoundary))
  908. COMPUTE_CORNER_PRED_DIFF(p1 - 128 + 64, iPredBefore[i][0]);
  909. if ((leftAdjacentColumn || bOneMBRightVertTB) && (bottom || bHoriTileBoundary))
  910. COMPUTE_CORNER_PRED_DIFF(p0 - 128 + 48, *(p0 - 128 + 112));
  911. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (bottom || bHoriTileBoundary))
  912. iPredBefore[i][1] = *(p0 + 48);
  913. if ((right || bVertTileBoundary) && (bottom || bHoriTileBoundary))
  914. COMPUTE_CORNER_PRED_DIFF(p0 - 128 + 112, iPredBefore[i][1]);
  915. if (!bottom)
  916. {
  917. if (leftORright || bVertTileBoundary)
  918. {
  919. if (!top && !bHoriTileBoundary)
  920. {
  921. if (left || bVertTileBoundary)
  922. strPre2(p0 + 48 + 0, p1 + 0);
  923. if (right || bVertTileBoundary)
  924. strPre2(p0 + 48 + -64, p1 + -64);
  925. }
  926. if (left || bVertTileBoundary)
  927. strPre2(p1 + 16, p1 + 16 + 16);
  928. if (right || bVertTileBoundary)
  929. strPre2(p1 + -48, p1 + -48 + 16);
  930. }
  931. if (!leftORright && !bVertTileBoundary)
  932. {
  933. if (top || bHoriTileBoundary)
  934. strPre2(p1 - 64, p1);
  935. else
  936. strPre2x2(p0 - 16, p0 + 48, p1 - 64, p1);
  937. strPre2x2(p1 - 48, p1 + 16, p1 - 32, p1 + 32);
  938. }
  939. }
  940. if ((bottom || bHoriTileBoundary) && (!leftORright && !bVertTileBoundary))
  941. strPre2(p0 - 16, p0 + 48);
  942. if ((leftAdjacentColumn || bOneMBRightVertTB) && (top || bHoriTileBoundary))
  943. COMPUTE_CORNER_PRED_ADD(p1 - 128 + 0, *(p1 - 128 + 64));
  944. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (top || bHoriTileBoundary))
  945. iPredAfter[i][0] = *(p1 + 0);
  946. if ((right || bVertTileBoundary) && (top || bHoriTileBoundary))
  947. COMPUTE_CORNER_PRED_ADD(p1 - 128 + 64, iPredAfter[i][0]);
  948. if ((leftAdjacentColumn || bOneMBRightVertTB) && (bottom || bHoriTileBoundary))
  949. COMPUTE_CORNER_PRED_ADD(p0 - 128 + 48, *(p0 - 128 + 112));
  950. if ((rightAdjacentColumn || bOneMBLeftVertTB) && (bottom || bHoriTileBoundary))
  951. iPredAfter[i][1] = *(p0 + 48);
  952. if ((right || bVertTileBoundary) && (bottom || bHoriTileBoundary))
  953. COMPUTE_CORNER_PRED_ADD(p0 - 128 + 112, iPredAfter[i][1]);
  954. }
  955. //================================
  956. // second level transform (422_UV)
  957. if (!topORleft)
  958. {
  959. if (!pSC->m_param.bScaledArith) {
  960. strDCT2x2dn(p0 - 128, p0 - 64, p0 - 112, p0 - 48);
  961. strDCT2x2dn(p0 - 96, p0 - 32, p0 - 80, p0 - 16);
  962. }
  963. else {
  964. strDCT2x2dnEnc(p0 - 128, p0 - 64, p0 - 112, p0 - 48);
  965. strDCT2x2dnEnc(p0 - 96, p0 - 32, p0 - 80, p0 - 16);
  966. }
  967. // 1D lossless HT
  968. p0[- 96] -= p0[-128];
  969. p0[-128] += ((p0[-96] + 1) >> 1);
  970. }
  971. }
  972. assert(NULL == p);
  973. }