| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379 |
- using Ryujinx.Graphics.Nvdec.Vp9.Common;
- namespace Ryujinx.Graphics.Nvdec.Vp9.Dsp
- {
- internal static class IntraPred
- {
- private static unsafe ref byte Dst(byte* dst, int stride, int x, int y)
- {
- return ref dst[x + y * stride];
- }
- private static unsafe ref ushort Dst(ushort* dst, int stride, int x, int y)
- {
- return ref dst[x + y * stride];
- }
- private static byte Avg3(byte a, byte b, byte c)
- {
- return (byte)((a + 2 * b + c + 2) >> 2);
- }
- private static ushort Avg3(ushort a, ushort b, ushort c)
- {
- return (ushort)((a + 2 * b + c + 2) >> 2);
- }
- private static byte Avg2(byte a, byte b)
- {
- return (byte)((a + b + 1) >> 1);
- }
- private static ushort Avg2(ushort a, ushort b)
- {
- return (ushort)((a + b + 1) >> 1);
- }
- public static unsafe void D207Predictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- D207Predictor(dst, stride, 8, above, left);
- }
- public static unsafe void D207Predictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- D207Predictor(dst, stride, 16, above, left);
- }
- public static unsafe void D207Predictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- D207Predictor(dst, stride, 32, above, left);
- }
- private static unsafe void D207Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r, c;
- // First column
- for (r = 0; r < bs - 1; ++r)
- {
- dst[r * stride] = Avg2(left[r], left[r + 1]);
- }
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // Second column
- for (r = 0; r < bs - 2; ++r)
- {
- dst[r * stride] = Avg3(left[r], left[r + 1], left[r + 2]);
- }
- dst[(bs - 2) * stride] = Avg3(left[bs - 2], left[bs - 1], left[bs - 1]);
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // Rest of last row
- for (c = 0; c < bs - 2; ++c)
- {
- dst[(bs - 1) * stride + c] = left[bs - 1];
- }
- for (r = bs - 2; r >= 0; --r)
- {
- for (c = 0; c < bs - 2; ++c)
- {
- dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
- }
- }
- }
- public static unsafe void D63Predictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- D63Predictor(dst, stride, 8, above, left);
- }
- public static unsafe void D63Predictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- D63Predictor(dst, stride, 16, above, left);
- }
- public static unsafe void D63Predictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- D63Predictor(dst, stride, 32, above, left);
- }
- private static unsafe void D63Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r, c;
- int size;
- for (c = 0; c < bs; ++c)
- {
- dst[c] = Avg2(above[c], above[c + 1]);
- dst[stride + c] = Avg3(above[c], above[c + 1], above[c + 2]);
- }
- for (r = 2, size = bs - 2; r < bs; r += 2, --size)
- {
- MemoryUtil.Copy(dst + (r + 0) * stride, dst + (r >> 1), size);
- MemoryUtil.Fill(dst + (r + 0) * stride + size, above[bs - 1], bs - size);
- MemoryUtil.Copy(dst + (r + 1) * stride, dst + stride + (r >> 1), size);
- MemoryUtil.Fill(dst + (r + 1) * stride + size, above[bs - 1], bs - size);
- }
- }
- public static unsafe void D45Predictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- D45Predictor(dst, stride, 8, above, left);
- }
- public static unsafe void D45Predictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- D45Predictor(dst, stride, 16, above, left);
- }
- public static unsafe void D45Predictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- D45Predictor(dst, stride, 32, above, left);
- }
- private static unsafe void D45Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- byte aboveRight = above[bs - 1];
- byte* dstRow0 = dst;
- int x, size;
- for (x = 0; x < bs - 1; ++x)
- {
- dst[x] = Avg3(above[x], above[x + 1], above[x + 2]);
- }
- dst[bs - 1] = aboveRight;
- dst += stride;
- for (x = 1, size = bs - 2; x < bs; ++x, --size)
- {
- MemoryUtil.Copy(dst, dstRow0 + x, size);
- MemoryUtil.Fill(dst + size, aboveRight, x + 1);
- dst += stride;
- }
- }
- public static unsafe void D117Predictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- D117Predictor(dst, stride, 8, above, left);
- }
- public static unsafe void D117Predictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- D117Predictor(dst, stride, 16, above, left);
- }
- public static unsafe void D117Predictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- D117Predictor(dst, stride, 32, above, left);
- }
- private static unsafe void D117Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r, c;
- // First row
- for (c = 0; c < bs; c++)
- {
- dst[c] = Avg2(above[c - 1], above[c]);
- }
- dst += stride;
- // Second row
- dst[0] = Avg3(left[0], above[-1], above[0]);
- for (c = 1; c < bs; c++)
- {
- dst[c] = Avg3(above[c - 2], above[c - 1], above[c]);
- }
- dst += stride;
- // The rest of first col
- dst[0] = Avg3(above[-1], left[0], left[1]);
- for (r = 3; r < bs; ++r)
- {
- dst[(r - 2) * stride] = Avg3(left[r - 3], left[r - 2], left[r - 1]);
- }
- // The rest of the block
- for (r = 2; r < bs; ++r)
- {
- for (c = 1; c < bs; c++)
- {
- dst[c] = dst[-2 * stride + c - 1];
- }
- dst += stride;
- }
- }
- public static unsafe void D135Predictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- D135Predictor(dst, stride, 8, above, left);
- }
- public static unsafe void D135Predictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- D135Predictor(dst, stride, 16, above, left);
- }
- public static unsafe void D135Predictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- D135Predictor(dst, stride, 32, above, left);
- }
- private static unsafe void D135Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int i;
- byte* border = stackalloc byte[32 + 32 - 1]; // outer border from bottom-left to top-right
- // Dst(dst, stride, bs, bs - 2)[0], i.e., border starting at bottom-left
- for (i = 0; i < bs - 2; ++i)
- {
- border[i] = Avg3(left[bs - 3 - i], left[bs - 2 - i], left[bs - 1 - i]);
- }
- border[bs - 2] = Avg3(above[-1], left[0], left[1]);
- border[bs - 1] = Avg3(left[0], above[-1], above[0]);
- border[bs - 0] = Avg3(above[-1], above[0], above[1]);
- // dst[0][2, size), i.e., remaining top border ascending
- for (i = 0; i < bs - 2; ++i)
- {
- border[bs + 1 + i] = Avg3(above[i], above[i + 1], above[i + 2]);
- }
- for (i = 0; i < bs; ++i)
- {
- MemoryUtil.Copy(dst + i * stride, border + bs - 1 - i, bs);
- }
- }
- public static unsafe void D153Predictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- D153Predictor(dst, stride, 8, above, left);
- }
- public static unsafe void D153Predictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- D153Predictor(dst, stride, 16, above, left);
- }
- public static unsafe void D153Predictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- D153Predictor(dst, stride, 32, above, left);
- }
- private static unsafe void D153Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r, c;
- dst[0] = Avg2(above[-1], left[0]);
- for (r = 1; r < bs; r++)
- {
- dst[r * stride] = Avg2(left[r - 1], left[r]);
- }
- dst++;
- dst[0] = Avg3(left[0], above[-1], above[0]);
- dst[stride] = Avg3(above[-1], left[0], left[1]);
- for (r = 2; r < bs; r++)
- {
- dst[r * stride] = Avg3(left[r - 2], left[r - 1], left[r]);
- }
- dst++;
- for (c = 0; c < bs - 2; c++)
- {
- dst[c] = Avg3(above[c - 1], above[c], above[c + 1]);
- }
- dst += stride;
- for (r = 1; r < bs; ++r)
- {
- for (c = 0; c < bs - 2; c++)
- {
- dst[c] = dst[-stride + c - 2];
- }
- dst += stride;
- }
- }
- public static unsafe void VPredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- VPredictor(dst, stride, 4, above, left);
- }
- public static unsafe void VPredictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- VPredictor(dst, stride, 8, above, left);
- }
- public static unsafe void VPredictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- VPredictor(dst, stride, 16, above, left);
- }
- public static unsafe void VPredictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- VPredictor(dst, stride, 32, above, left);
- }
- private static unsafe void VPredictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Copy(dst, above, bs);
- dst += stride;
- }
- }
- public static unsafe void HPredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- HPredictor(dst, stride, 4, above, left);
- }
- public static unsafe void HPredictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- HPredictor(dst, stride, 8, above, left);
- }
- public static unsafe void HPredictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- HPredictor(dst, stride, 16, above, left);
- }
- public static unsafe void HPredictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- HPredictor(dst, stride, 32, above, left);
- }
- private static unsafe void HPredictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, left[r], bs);
- dst += stride;
- }
- }
- public static unsafe void TMPredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- TMPredictor(dst, stride, 4, above, left);
- }
- public static unsafe void TMPredictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- TMPredictor(dst, stride, 8, above, left);
- }
- public static unsafe void TMPredictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- TMPredictor(dst, stride, 16, above, left);
- }
- public static unsafe void TMPredictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- TMPredictor(dst, stride, 32, above, left);
- }
- private static unsafe void TMPredictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r, c;
- int yTopLeft = above[-1];
- for (r = 0; r < bs; r++)
- {
- for (c = 0; c < bs; c++)
- {
- dst[c] = BitUtils.ClipPixel(left[r] + above[c] - yTopLeft);
- }
- dst += stride;
- }
- }
- public static unsafe void Dc128Predictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- Dc128Predictor(dst, stride, 4, above, left);
- }
- public static unsafe void Dc128Predictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- Dc128Predictor(dst, stride, 8, above, left);
- }
- public static unsafe void Dc128Predictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- Dc128Predictor(dst, stride, 16, above, left);
- }
- public static unsafe void Dc128Predictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- Dc128Predictor(dst, stride, 32, above, left);
- }
- private static unsafe void Dc128Predictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int r;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (byte)128, bs);
- dst += stride;
- }
- }
- public static unsafe void DcLeftPredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- DcLeftPredictor(dst, stride, 4, above, left);
- }
- public static unsafe void DcLeftPredictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- DcLeftPredictor(dst, stride, 8, above, left);
- }
- public static unsafe void DcLeftPredictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- DcLeftPredictor(dst, stride, 16, above, left);
- }
- public static unsafe void DcLeftPredictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- DcLeftPredictor(dst, stride, 32, above, left);
- }
- private static unsafe void DcLeftPredictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int i, r, expectedDc, sum = 0;
- for (i = 0; i < bs; i++)
- {
- sum += left[i];
- }
- expectedDc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (byte)expectedDc, bs);
- dst += stride;
- }
- }
- public static unsafe void DcTopPredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- DcTopPredictor(dst, stride, 4, above, left);
- }
- public static unsafe void DcTopPredictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- DcTopPredictor(dst, stride, 8, above, left);
- }
- public static unsafe void DcTopPredictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- DcTopPredictor(dst, stride, 16, above, left);
- }
- public static unsafe void DcTopPredictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- DcTopPredictor(dst, stride, 32, above, left);
- }
- private static unsafe void DcTopPredictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int i, r, expectedDc, sum = 0;
- for (i = 0; i < bs; i++)
- {
- sum += above[i];
- }
- expectedDc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (byte)expectedDc, bs);
- dst += stride;
- }
- }
- public static unsafe void DcPredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- DcPredictor(dst, stride, 4, above, left);
- }
- public static unsafe void DcPredictor8x8(byte* dst, int stride, byte* above, byte* left)
- {
- DcPredictor(dst, stride, 8, above, left);
- }
- public static unsafe void DcPredictor16x16(byte* dst, int stride, byte* above, byte* left)
- {
- DcPredictor(dst, stride, 16, above, left);
- }
- public static unsafe void DcPredictor32x32(byte* dst, int stride, byte* above, byte* left)
- {
- DcPredictor(dst, stride, 32, above, left);
- }
- private static unsafe void DcPredictor(byte* dst, int stride, int bs, byte* above, byte* left)
- {
- int i, r, expectedDc, sum = 0;
- int count = 2 * bs;
- for (i = 0; i < bs; i++)
- {
- sum += above[i];
- sum += left[i];
- }
- expectedDc = (sum + (count >> 1)) / count;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (byte)expectedDc, bs);
- dst += stride;
- }
- }
- public static unsafe void HePredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte h = above[-1];
- byte I = left[0];
- byte j = left[1];
- byte k = left[2];
- byte l = left[3];
- MemoryUtil.Fill(dst + stride * 0, Avg3(h, I, j), 4);
- MemoryUtil.Fill(dst + stride * 1, Avg3(I, j, k), 4);
- MemoryUtil.Fill(dst + stride * 2, Avg3(j, k, l), 4);
- MemoryUtil.Fill(dst + stride * 3, Avg3(k, l, l), 4);
- }
- public static unsafe void VePredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte h = above[-1];
- byte I = above[0];
- byte j = above[1];
- byte k = above[2];
- byte l = above[3];
- byte m = above[4];
- dst[0] = Avg3(h, I, j);
- dst[1] = Avg3(I, j, k);
- dst[2] = Avg3(j, k, l);
- dst[3] = Avg3(k, l, m);
- MemoryUtil.Copy(dst + stride * 1, dst, 4);
- MemoryUtil.Copy(dst + stride * 2, dst, 4);
- MemoryUtil.Copy(dst + stride * 3, dst, 4);
- }
- public static unsafe void D207Predictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte I = left[0];
- byte j = left[1];
- byte k = left[2];
- byte l = left[3];
- Dst(dst, stride, 0, 0) = Avg2(I, j);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 0, 1) = Avg2(j, k);
- Dst(dst, stride, 2, 1) = Dst(dst, stride, 0, 2) = Avg2(k, l);
- Dst(dst, stride, 1, 0) = Avg3(I, j, k);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 1, 1) = Avg3(j, k, l);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 1, 2) = Avg3(k, l, l);
- Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 0, 3) = Dst(dst, stride, 1, 3) = Dst(dst, stride, 2, 3) = Dst(dst, stride, 3, 3) = l;
- }
- public static unsafe void D63Predictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte a = above[0];
- byte b = above[1];
- byte c = above[2];
- byte d = above[3];
- byte e = above[4];
- byte f = above[5];
- byte g = above[6];
- Dst(dst, stride, 0, 0) = Avg2(a, b);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 2) = Avg2(b, c);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 2) = Avg2(c, d);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 2) = Avg2(d, e);
- Dst(dst, stride, 3, 2) = Avg2(e, f); // Differs from vp8
- Dst(dst, stride, 0, 1) = Avg3(a, b, c);
- Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 3) = Avg3(b, c, d);
- Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 3) = Avg3(c, d, e);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 3) = Avg3(d, e, f);
- Dst(dst, stride, 3, 3) = Avg3(e, f, g); // Differs from vp8
- }
- public static unsafe void D63ePredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte a = above[0];
- byte b = above[1];
- byte c = above[2];
- byte d = above[3];
- byte e = above[4];
- byte f = above[5];
- byte g = above[6];
- byte h = above[7];
- Dst(dst, stride, 0, 0) = Avg2(a, b);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 2) = Avg2(b, c);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 2) = Avg2(c, d);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 2) = Avg2(d, e);
- Dst(dst, stride, 3, 2) = Avg3(e, f, g);
- Dst(dst, stride, 0, 1) = Avg3(a, b, c);
- Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 3) = Avg3(b, c, d);
- Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 3) = Avg3(c, d, e);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 3) = Avg3(d, e, f);
- Dst(dst, stride, 3, 3) = Avg3(f, g, h);
- }
- public static unsafe void D45Predictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte a = above[0];
- byte b = above[1];
- byte c = above[2];
- byte d = above[3];
- byte e = above[4];
- byte f = above[5];
- byte g = above[6];
- byte h = above[7];
- Dst(dst, stride, 0, 0) = Avg3(a, b, c);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 1) = Avg3(b, c, d);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 2) = Avg3(c, d, e);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 2) = Dst(dst, stride, 0, 3) = Avg3(d, e, f);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 1, 3) = Avg3(e, f, g);
- Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 3) = Avg3(f, g, h);
- Dst(dst, stride, 3, 3) = h; // differs from vp8
- }
- public static unsafe void D45ePredictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte a = above[0];
- byte b = above[1];
- byte c = above[2];
- byte d = above[3];
- byte e = above[4];
- byte f = above[5];
- byte g = above[6];
- byte h = above[7];
- Dst(dst, stride, 0, 0) = Avg3(a, b, c);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 1) = Avg3(b, c, d);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 2) = Avg3(c, d, e);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 2) = Dst(dst, stride, 0, 3) = Avg3(d, e, f);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 1, 3) = Avg3(e, f, g);
- Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 3) = Avg3(f, g, h);
- Dst(dst, stride, 3, 3) = Avg3(g, h, h);
- }
- public static unsafe void D117Predictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte I = left[0];
- byte j = left[1];
- byte k = left[2];
- byte x = above[-1];
- byte a = above[0];
- byte b = above[1];
- byte c = above[2];
- byte d = above[3];
- Dst(dst, stride, 0, 0) = Dst(dst, stride, 1, 2) = Avg2(x, a);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 2, 2) = Avg2(a, b);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 3, 2) = Avg2(b, c);
- Dst(dst, stride, 3, 0) = Avg2(c, d);
- Dst(dst, stride, 0, 3) = Avg3(k, j, I);
- Dst(dst, stride, 0, 2) = Avg3(j, I, x);
- Dst(dst, stride, 0, 1) = Dst(dst, stride, 1, 3) = Avg3(I, x, a);
- Dst(dst, stride, 1, 1) = Dst(dst, stride, 2, 3) = Avg3(x, a, b);
- Dst(dst, stride, 2, 1) = Dst(dst, stride, 3, 3) = Avg3(a, b, c);
- Dst(dst, stride, 3, 1) = Avg3(b, c, d);
- }
- public static unsafe void D135Predictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte I = left[0];
- byte j = left[1];
- byte k = left[2];
- byte l = left[3];
- byte x = above[-1];
- byte a = above[0];
- byte b = above[1];
- byte c = above[2];
- byte d = above[3];
- Dst(dst, stride, 0, 3) = Avg3(j, k, l);
- Dst(dst, stride, 1, 3) = Dst(dst, stride, 0, 2) = Avg3(I, j, k);
- Dst(dst, stride, 2, 3) = Dst(dst, stride, 1, 2) = Dst(dst, stride, 0, 1) = Avg3(x, I, j);
- Dst(dst, stride, 3, 3) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 0) = Avg3(a, x, I);
- Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 0) = Avg3(b, a, x);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 0) = Avg3(c, b, a);
- Dst(dst, stride, 3, 0) = Avg3(d, c, b);
- }
- public static unsafe void D153Predictor4x4(byte* dst, int stride, byte* above, byte* left)
- {
- byte I = left[0];
- byte j = left[1];
- byte k = left[2];
- byte l = left[3];
- byte x = above[-1];
- byte a = above[0];
- byte b = above[1];
- byte c = above[2];
- Dst(dst, stride, 0, 0) = Dst(dst, stride, 2, 1) = Avg2(I, x);
- Dst(dst, stride, 0, 1) = Dst(dst, stride, 2, 2) = Avg2(j, I);
- Dst(dst, stride, 0, 2) = Dst(dst, stride, 2, 3) = Avg2(k, j);
- Dst(dst, stride, 0, 3) = Avg2(l, k);
- Dst(dst, stride, 3, 0) = Avg3(a, b, c);
- Dst(dst, stride, 2, 0) = Avg3(x, a, b);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 3, 1) = Avg3(I, x, a);
- Dst(dst, stride, 1, 1) = Dst(dst, stride, 3, 2) = Avg3(j, I, x);
- Dst(dst, stride, 1, 2) = Dst(dst, stride, 3, 3) = Avg3(k, j, I);
- Dst(dst, stride, 1, 3) = Avg3(l, k, j);
- }
- public static unsafe void HighbdD207Predictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD207Predictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdD207Predictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD207Predictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdD207Predictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD207Predictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdD207Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r, c;
- // First column.
- for (r = 0; r < bs - 1; ++r)
- {
- dst[r * stride] = Avg2(left[r], left[r + 1]);
- }
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // Second column.
- for (r = 0; r < bs - 2; ++r)
- {
- dst[r * stride] = Avg3(left[r], left[r + 1], left[r + 2]);
- }
- dst[(bs - 2) * stride] = Avg3(left[bs - 2], left[bs - 1], left[bs - 1]);
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // Rest of last row.
- for (c = 0; c < bs - 2; ++c)
- {
- dst[(bs - 1) * stride + c] = left[bs - 1];
- }
- for (r = bs - 2; r >= 0; --r)
- {
- for (c = 0; c < bs - 2; ++c)
- {
- dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
- }
- }
- }
- public static unsafe void HighbdD63Predictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD63Predictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdD63Predictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD63Predictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdD63Predictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD63Predictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdD63Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r, c;
- int size;
- for (c = 0; c < bs; ++c)
- {
- dst[c] = Avg2(above[c], above[c + 1]);
- dst[stride + c] = Avg3(above[c], above[c + 1], above[c + 2]);
- }
- for (r = 2, size = bs - 2; r < bs; r += 2, --size)
- {
- MemoryUtil.Copy(dst + (r + 0) * stride, dst + (r >> 1), size);
- MemoryUtil.Fill(dst + (r + 0) * stride + size, above[bs - 1], bs - size);
- MemoryUtil.Copy(dst + (r + 1) * stride, dst + stride + (r >> 1), size);
- MemoryUtil.Fill(dst + (r + 1) * stride + size, above[bs - 1], bs - size);
- }
- }
- public static unsafe void HighbdD45Predictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD45Predictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdD45Predictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD45Predictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdD45Predictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD45Predictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdD45Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- ushort aboveRight = above[bs - 1];
- ushort* dstRow0 = dst;
- int x, size;
- for (x = 0; x < bs - 1; ++x)
- {
- dst[x] = Avg3(above[x], above[x + 1], above[x + 2]);
- }
- dst[bs - 1] = aboveRight;
- dst += stride;
- for (x = 1, size = bs - 2; x < bs; ++x, --size)
- {
- MemoryUtil.Copy(dst, dstRow0 + x, size);
- MemoryUtil.Fill(dst + size, aboveRight, x + 1);
- dst += stride;
- }
- }
- public static unsafe void HighbdD117Predictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD117Predictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdD117Predictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD117Predictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdD117Predictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD117Predictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdD117Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r, c;
- // First row
- for (c = 0; c < bs; c++)
- {
- dst[c] = Avg2(above[c - 1], above[c]);
- }
- dst += stride;
- // Second row
- dst[0] = Avg3(left[0], above[-1], above[0]);
- for (c = 1; c < bs; c++)
- {
- dst[c] = Avg3(above[c - 2], above[c - 1], above[c]);
- }
- dst += stride;
- // The rest of first col
- dst[0] = Avg3(above[-1], left[0], left[1]);
- for (r = 3; r < bs; ++r)
- {
- dst[(r - 2) * stride] = Avg3(left[r - 3], left[r - 2], left[r - 1]);
- }
- // The rest of the block
- for (r = 2; r < bs; ++r)
- {
- for (c = 1; c < bs; c++)
- {
- dst[c] = dst[-2 * stride + c - 1];
- }
- dst += stride;
- }
- }
- public static unsafe void HighbdD135Predictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD135Predictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdD135Predictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD135Predictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdD135Predictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD135Predictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdD135Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int i;
- ushort* border = stackalloc ushort[32 + 32 - 1]; // Outer border from bottom-left to top-right
- // Dst(dst, stride, bs, bs - 2)[0], i.e., border starting at bottom-left
- for (i = 0; i < bs - 2; ++i)
- {
- border[i] = Avg3(left[bs - 3 - i], left[bs - 2 - i], left[bs - 1 - i]);
- }
- border[bs - 2] = Avg3(above[-1], left[0], left[1]);
- border[bs - 1] = Avg3(left[0], above[-1], above[0]);
- border[bs - 0] = Avg3(above[-1], above[0], above[1]);
- // dst[0][2, size), i.e., remaining top border ascending
- for (i = 0; i < bs - 2; ++i)
- {
- border[bs + 1 + i] = Avg3(above[i], above[i + 1], above[i + 2]);
- }
- for (i = 0; i < bs; ++i)
- {
- MemoryUtil.Copy(dst + i * stride, border + bs - 1 - i, bs);
- }
- }
- public static unsafe void HighbdD153Predictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD153Predictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdD153Predictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD153Predictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdD153Predictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdD153Predictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdD153Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r, c;
- dst[0] = Avg2(above[-1], left[0]);
- for (r = 1; r < bs; r++)
- {
- dst[r * stride] = Avg2(left[r - 1], left[r]);
- }
- dst++;
- dst[0] = Avg3(left[0], above[-1], above[0]);
- dst[stride] = Avg3(above[-1], left[0], left[1]);
- for (r = 2; r < bs; r++)
- {
- dst[r * stride] = Avg3(left[r - 2], left[r - 1], left[r]);
- }
- dst++;
- for (c = 0; c < bs - 2; c++)
- {
- dst[c] = Avg3(above[c - 1], above[c], above[c + 1]);
- }
- dst += stride;
- for (r = 1; r < bs; ++r)
- {
- for (c = 0; c < bs - 2; c++)
- {
- dst[c] = dst[-stride + c - 2];
- }
- dst += stride;
- }
- }
- public static unsafe void HighbdVPredictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdVPredictor(dst, stride, 4, above, left, bd);
- }
- public static unsafe void HighbdVPredictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdVPredictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdVPredictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdVPredictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdVPredictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdVPredictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdVPredictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Copy(dst, above, bs);
- dst += stride;
- }
- }
- public static unsafe void HighbdHPredictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdHPredictor(dst, stride, 4, above, left, bd);
- }
- public static unsafe void HighbdHPredictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdHPredictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdHPredictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdHPredictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdHPredictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdHPredictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdHPredictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, left[r], bs);
- dst += stride;
- }
- }
- public static unsafe void HighbdTMPredictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdTMPredictor(dst, stride, 4, above, left, bd);
- }
- public static unsafe void HighbdTMPredictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdTMPredictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdTMPredictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdTMPredictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdTMPredictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdTMPredictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdTMPredictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r, c;
- int yTopLeft = above[-1];
- for (r = 0; r < bs; r++)
- {
- for (c = 0; c < bs; c++)
- {
- dst[c] = BitUtils.ClipPixelHighbd(left[r] + above[c] - yTopLeft, bd);
- }
- dst += stride;
- }
- }
- public static unsafe void HighbdDc128Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDc128Predictor(dst, stride, 4, above, left, bd);
- }
- public static unsafe void HighbdDc128Predictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDc128Predictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdDc128Predictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDc128Predictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdDc128Predictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDc128Predictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdDc128Predictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int r;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (ushort)(128 << (bd - 8)), bs);
- dst += stride;
- }
- }
- public static unsafe void HighbdDcLeftPredictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcLeftPredictor(dst, stride, 4, above, left, bd);
- }
- public static unsafe void HighbdDcLeftPredictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcLeftPredictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdDcLeftPredictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcLeftPredictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdDcLeftPredictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcLeftPredictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdDcLeftPredictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int i, r, expectedDc, sum = 0;
- for (i = 0; i < bs; i++)
- {
- sum += left[i];
- }
- expectedDc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (ushort)expectedDc, bs);
- dst += stride;
- }
- }
- public static unsafe void HighbdDcTopPredictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcTopPredictor(dst, stride, 4, above, left, bd);
- }
- public static unsafe void HighbdDcTopPredictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcTopPredictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdDcTopPredictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcTopPredictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdDcTopPredictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcTopPredictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdDcTopPredictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int i, r, expectedDc, sum = 0;
- for (i = 0; i < bs; i++)
- {
- sum += above[i];
- }
- expectedDc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (ushort)expectedDc, bs);
- dst += stride;
- }
- }
- public static unsafe void HighbdDcPredictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcPredictor(dst, stride, 4, above, left, bd);
- }
- public static unsafe void HighbdDcPredictor8x8(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcPredictor(dst, stride, 8, above, left, bd);
- }
- public static unsafe void HighbdDcPredictor16x16(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcPredictor(dst, stride, 16, above, left, bd);
- }
- public static unsafe void HighbdDcPredictor32x32(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- HighbdDcPredictor(dst, stride, 32, above, left, bd);
- }
- private static unsafe void HighbdDcPredictor(ushort* dst, int stride, int bs, ushort* above, ushort* left, int bd)
- {
- int i, r, expectedDc, sum = 0;
- int count = 2 * bs;
- for (i = 0; i < bs; i++)
- {
- sum += above[i];
- sum += left[i];
- }
- expectedDc = (sum + (count >> 1)) / count;
- for (r = 0; r < bs; r++)
- {
- MemoryUtil.Fill(dst, (ushort)expectedDc, bs);
- dst += stride;
- }
- }
- public static unsafe void HighbdD207Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- ushort I = left[0];
- ushort j = left[1];
- ushort k = left[2];
- ushort l = left[3];
- Dst(dst, stride, 0, 0) = Avg2(I, j);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 0, 1) = Avg2(j, k);
- Dst(dst, stride, 2, 1) = Dst(dst, stride, 0, 2) = Avg2(k, l);
- Dst(dst, stride, 1, 0) = Avg3(I, j, k);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 1, 1) = Avg3(j, k, l);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 1, 2) = Avg3(k, l, l);
- Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 0, 3) = Dst(dst, stride, 1, 3) = Dst(dst, stride, 2, 3) = Dst(dst, stride, 3, 3) = l;
- }
- public static unsafe void HighbdD63Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- ushort a = above[0];
- ushort b = above[1];
- ushort c = above[2];
- ushort d = above[3];
- ushort e = above[4];
- ushort f = above[5];
- ushort g = above[6];
- Dst(dst, stride, 0, 0) = Avg2(a, b);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 2) = Avg2(b, c);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 2) = Avg2(c, d);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 2) = Avg2(d, e);
- Dst(dst, stride, 3, 2) = Avg2(e, f); // Differs from vp8
- Dst(dst, stride, 0, 1) = Avg3(a, b, c);
- Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 3) = Avg3(b, c, d);
- Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 3) = Avg3(c, d, e);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 3) = Avg3(d, e, f);
- Dst(dst, stride, 3, 3) = Avg3(e, f, g); // Differs from vp8
- }
- public static unsafe void HighbdD45Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- ushort a = above[0];
- ushort b = above[1];
- ushort c = above[2];
- ushort d = above[3];
- ushort e = above[4];
- ushort f = above[5];
- ushort g = above[6];
- ushort h = above[7];
- Dst(dst, stride, 0, 0) = Avg3(a, b, c);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 0, 1) = Avg3(b, c, d);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 2) = Avg3(c, d, e);
- Dst(dst, stride, 3, 0) = Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 2) = Dst(dst, stride, 0, 3) = Avg3(d, e, f);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 1, 3) = Avg3(e, f, g);
- Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 3) = Avg3(f, g, h);
- Dst(dst, stride, 3, 3) = h; // Differs from vp8
- }
- public static unsafe void HighbdD117Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- ushort I = left[0];
- ushort j = left[1];
- ushort k = left[2];
- ushort x = above[-1];
- ushort a = above[0];
- ushort b = above[1];
- ushort c = above[2];
- ushort d = above[3];
- Dst(dst, stride, 0, 0) = Dst(dst, stride, 1, 2) = Avg2(x, a);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 2, 2) = Avg2(a, b);
- Dst(dst, stride, 2, 0) = Dst(dst, stride, 3, 2) = Avg2(b, c);
- Dst(dst, stride, 3, 0) = Avg2(c, d);
- Dst(dst, stride, 0, 3) = Avg3(k, j, I);
- Dst(dst, stride, 0, 2) = Avg3(j, I, x);
- Dst(dst, stride, 0, 1) = Dst(dst, stride, 1, 3) = Avg3(I, x, a);
- Dst(dst, stride, 1, 1) = Dst(dst, stride, 2, 3) = Avg3(x, a, b);
- Dst(dst, stride, 2, 1) = Dst(dst, stride, 3, 3) = Avg3(a, b, c);
- Dst(dst, stride, 3, 1) = Avg3(b, c, d);
- }
- public static unsafe void HighbdD135Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- ushort I = left[0];
- ushort j = left[1];
- ushort k = left[2];
- ushort l = left[3];
- ushort x = above[-1];
- ushort a = above[0];
- ushort b = above[1];
- ushort c = above[2];
- ushort d = above[3];
- Dst(dst, stride, 0, 3) = Avg3(j, k, l);
- Dst(dst, stride, 1, 3) = Dst(dst, stride, 0, 2) = Avg3(I, j, k);
- Dst(dst, stride, 2, 3) = Dst(dst, stride, 1, 2) = Dst(dst, stride, 0, 1) = Avg3(x, I, j);
- Dst(dst, stride, 3, 3) = Dst(dst, stride, 2, 2) = Dst(dst, stride, 1, 1) = Dst(dst, stride, 0, 0) = Avg3(a, x, I);
- Dst(dst, stride, 3, 2) = Dst(dst, stride, 2, 1) = Dst(dst, stride, 1, 0) = Avg3(b, a, x);
- Dst(dst, stride, 3, 1) = Dst(dst, stride, 2, 0) = Avg3(c, b, a);
- Dst(dst, stride, 3, 0) = Avg3(d, c, b);
- }
- public static unsafe void HighbdD153Predictor4x4(ushort* dst, int stride, ushort* above, ushort* left, int bd)
- {
- ushort I = left[0];
- ushort j = left[1];
- ushort k = left[2];
- ushort l = left[3];
- ushort x = above[-1];
- ushort a = above[0];
- ushort b = above[1];
- ushort c = above[2];
- Dst(dst, stride, 0, 0) = Dst(dst, stride, 2, 1) = Avg2(I, x);
- Dst(dst, stride, 0, 1) = Dst(dst, stride, 2, 2) = Avg2(j, I);
- Dst(dst, stride, 0, 2) = Dst(dst, stride, 2, 3) = Avg2(k, j);
- Dst(dst, stride, 0, 3) = Avg2(l, k);
- Dst(dst, stride, 3, 0) = Avg3(a, b, c);
- Dst(dst, stride, 2, 0) = Avg3(x, a, b);
- Dst(dst, stride, 1, 0) = Dst(dst, stride, 3, 1) = Avg3(I, x, a);
- Dst(dst, stride, 1, 1) = Dst(dst, stride, 3, 2) = Avg3(j, I, x);
- Dst(dst, stride, 1, 2) = Dst(dst, stride, 3, 3) = Avg3(k, j, I);
- Dst(dst, stride, 1, 3) = Avg3(l, k, j);
- }
- }
- }
|