[x265] hdr: maxCLL/maxFALL convert YUV to RGB domain, and then to linear luminance levels
Deepthi Nandakumar
deepthi at multicorewareinc.com
Thu Mar 24 04:52:02 CET 2016
# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1458630685 -19800
# Tue Mar 22 12:41:25 2016 +0530
# Node ID 2860b4d8bd682e8d0fe2a08b1e16198feb696230
# Parent 2de6cb99313a03c3577934ac5e2e116f7ba6cd10
hdr: maxCLL/maxFALL convert YUV to RGB domain, and then to linear luminance
levels
miscellaneous cleanup, move PIXEL_MAX to common
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/common.h
--- a/source/common/common.h Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/common.h Tue Mar 22 12:41:25 2016 +0530
@@ -322,6 +322,8 @@
#define MAX_NUM_TR_COEFFS MAX_TR_SIZE * MAX_TR_SIZE // Maximum
number of transform coefficients, for a 32x32 transform
#define MAX_NUM_TR_CATEGORIES 16 // 32, 16,
8, 4 transform categories each for luma and chroma
+#define PIXEL_MAX ((1 << X265_DEPTH) - 1)
+
namespace X265_NS {
enum { SAO_NUM_OFFSET = 4 };
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/constants.cpp
--- a/source/common/constants.cpp Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/constants.cpp Tue Mar 22 12:41:25 2016 +0530
@@ -568,6 +568,7 @@
{ 42, 43, 46, 47, 58, 59, 62, 63, }
};
+/* Rec.2020 YUV to RGB Non-constant luminance */
const double g_YUVtoRGB_BT2020[3][3] =
{
{ 1.00, 0.00, 1.47460, },
@@ -575,4 +576,228 @@
{ 1.00, 1.88140, 0.00, }
};
+const double g_ST2084_PQTable[MAX_HDR_LEGAL_RANGE - MIN_HDR_LEGAL_RANGE +
1] =
+{
+ 0,
+ 5.25912035416561E-05, 0.000170826479250824, 0.000342874260206259,
0.000565730978088069,
+ 0.000838361593599196, 0.0011605708550711, 0.00153261170332205,
0.00195500928122658,
+ 0.00242846920816411, 0.00295382484798614, 0.00353200479131171,
0.00416401171798929,
+ 0.00485090808272845, 0.00559380610060962, 0.00639386055422149,
0.00725226351560689,
+ 0.0081702404049783, 0.00914904700558975, 0.010189967177051,
0.0112943110883226,
+ 0.0124634138437419, 0.0136986344106386, 0.0150013547814312,
0.0163729793201926,
+ 0.0178149342559234, 0.0193286672936668, 0.0209156473211494,
0.022577364193536,
+ 0.0243153285825585, 0.0261310718791221, 0.0280261461406398,
0.0300021240760516,
+ 0.0320605990628007, 0.0342031851910785, 0.036431517331512,
0.0387472512230819,
+ 0.0411520635786705, 0.0436476522060052, 0.046235736142162,
0.0489180558000865,
+ 0.0516963731258075, 0.0545724717652363, 0.0575481572396137,
0.0606252571287911,
+ 0.0638056212616694, 0.0670911219131892, 0.0704836540073949,
0.0739851353261047,
+ 0.0775975067228409, 0.0813227323416811, 0.0851627998407477,
0.0891197206201265,
+ 0.0931955300539647, 0.0973922877266004, 0.101712077672541,
0.106157008620188,
+ 0.110729214239187, 0.115430853391267, 0.120264110384523,
0.125231195231086,
+ 0.130334343908053, 0.135575818621706, 0.140957908074883,
0.146482927737596,
+ 0.152153220120717, 0.157971155052834, 0.163939129960184,
0.170059570149691,
+ 0.176334929095073, 0.182767688726043, 0.189360359720598,
0.196115481800328,
+ 0.203035624028883, 0.210123385113499, 0.21738139370961,
0.224812308728624,
+ 0.232418819648774, 0.240203646829142, 0.248169541826838,
0.256319287717358,
+ 0.264655699418179, 0.273181624015456, 0.281899941094164,
0.29081356307129,
+ 0.299925435532481, 0.309238537571936, 0.318755882135647,
0.32848051636804,
+ 0.338415521962, 0.34856401551231, 0.358929148872555, 0.369514109515577,
+ 0.380322120897342, 0.391356442824469, 0.402620371825233,
0.414117241524302,
+ 0.425850423021013, 0.437823325271459, 0.450039395474131,
0.4625021194595,
+ 0.475215022083238, 0.488181667623337, 0.501405660181076,
0.514890644085913,
+ 0.528640304304275, 0.542658366852319, 0.556948599212766,
0.571514810755682,
+ 0.58636085316357, 0.601490620860234, 0.616908051444177,
0.632617126126042,
+ 0.648621870170268, 0.664926353341107, 0.681534690353104,
0.6984510413256,
+ 0.715679612242097, 0.733224655413817, 0.751090469947712,
0.769281402219399,
+ 0.78780184635024, 0.806656244689427, 0.82584908830055,
0.84538491745295,
+ 0.865268322117971, 0.885503942469945, 0.906096469391926,
0.927050644986733,
+ 0.948371263092526, 0.970063169803824, 0.99213126399724,
1.01458049786256,
+ 1.03741587743901, 1.06064246315667, 1.08426537038311, 1.10828976997558,
+ 1.13272088883845, 1.1575640104859, 1.18282447561067, 1.20850768265765,
+ 1.23461908840365, 1.26116420854251, 1.28814861827608, 1.31557795291099,
+ 1.34345790846097, 1.37179424225547, 1.40059277355414, 1.42985938416685,
+ 1.45960001908056, 1.48982068709166, 1.52052746144494, 1.55172648047831,
+ 1.58342394827458, 1.61562613531883, 1.6483393791628, 1.68157008509547,
+ 1.71532472682031, 1.74960984713914, 1.78443205864284, 1.81979804440872,
+ 1.85571455870433, 1.8921884276992, 1.92922655018235, 1.9668358982877,
+ 2.0050235182263, 2.04379653102551, 2.0831621332761, 2.12312759788576,
+ 2.16370027484092, 2.20488759197549, 2.2466970557472, 2.28913625202187,
+ 2.33221284686502, 2.37593458734142, 2.42030930232274, 2.46534490330251,
+ 2.51104938521982, 2.55743082729067, 2.60449739384781, 2.65225733518805,
+ 2.70071898842928, 2.74989077837451, 2.79978121838576, 2.85039891126499,
+ 2.90175255014517, 2.95385091938954, 3.00670289549934, 3.06031744803115,
+ 3.11470364052283, 3.16987063142876, 3.22582767506471, 3.2825841225609,
+ 3.3401494228253, 3.39853312351689, 3.45774487202715, 3.51779441647257,
+ 3.57869160669604, 3.64044639527875, 3.7030688385618, 3.76656909767725,
+ 3.83095743959148, 3.89624423815599, 3.96243997517042, 4.02955524145598,
+ 4.09760073793895, 4.16658727674518, 4.2365257823051, 4.30742729247016,
+ 4.37930295964014, 4.45216405190141, 4.52602195417663, 4.60088816938553,
+ 4.67677431961831, 4.75369214731843, 4.83165351647993, 4.91067041385396,
+ 4.99075495016979, 5.07191936136577, 5.15417600983301, 5.23753738567282,
+ 5.32201610796449, 5.40762492604782, 5.49437672081637, 5.58228450602463,
+ 5.67136142960816, 5.76162077501684, 5.85307596256082, 5.94574055077076,
+ 6.03962823777015, 6.13475286266291, 6.2311284069342, 6.32876899586396,
+ 6.42768889995753, 6.5279025363866, 6.62942447044656, 6.73226941703026,
+ 6.83645224211186, 6.94198796425035, 7.04889175610325, 7.15717894596024,
+ 7.2668650192892, 7.37796562029657, 7.49049655350635, 7.60447378535363,
+ 7.71991344579293, 7.83683182992318, 7.95524539963073, 8.07517078524564,
+ 8.19662478721649, 8.31962437780235, 8.44418670277909, 8.57032908316786,
+ 8.69806901697162, 8.82742418094208, 8.95841243235119, 9.09105181078918,
+ 9.22536053997842, 9.36135702960081, 9.4990598771529, 9.63848786980913,
+ 9.77965998631185, 9.92259539887546, 10.0673134751131, 10.2138337799773,
+ 10.3621760777285, 10.5123603339148, 10.6644067173761, 10.8183356022682,
+ 10.9741675701064, 11.1319234118292, 11.2916241298841, 11.4532909403319,
+ 11.6169452749761, 11.782608783511, 11.9503033356888, 12.120051023515,
+ 12.2918741634627, 12.4657952987048, 12.6418372013776, 12.8200228748588,
+ 13.0003755560757, 13.1829187178276, 13.367676071144, 13.5546715676512,
+ 13.7439294019804, 13.9354740141834, 14.1293300921851, 14.3255225742508,
+ 14.5240766514895, 14.7250177703705, 14.9283716352778, 15.1341642110757,
+ 15.3424217257167, 15.5531706728631, 15.7664378145379, 15.9822501838117,
+ 16.2006350874992, 16.4216201089027, 16.6452331105667, 16.8715022370722,
+ 17.1004559178516, 17.3321228700381, 17.5665321013393, 17.8037129129401,
+ 18.0436949024415, 18.2865079668192, 18.5321823054235, 18.7807484229967,
+ 19.0322371327346, 19.2866795593684, 19.5441071422852, 19.8045516386728,
+ 20.068045126707, 20.3346200087623, 20.6043090146575, 20.8771452049349,
+ 21.1531619741772, 21.4323930543496, 21.7148725181833, 22.0006347825899,
+ 22.2897146121093, 22.5821471224015, 22.8779677837589, 23.1772124246723,
+ 23.4799172354157, 23.7861187716811, 24.0958539582449, 24.4091600926726,
+ 24.7260748490581, 25.0466362818137, 25.3708828294739, 25.6988533185695,
+ 26.0305869675189, 26.3661233905639, 26.7055026017538, 27.0487650189598,
+ 27.3959514679386, 27.7471031864343, 28.1022618283194, 28.4614694677879,
+ 28.8247686035749, 29.1922021632471, 29.5638135074984, 29.9396464345297,
+ 30.3197451844465, 30.7041544437129, 31.0929193496474, 31.4860854949729,
+ 31.8836989324014, 32.2858061792735, 32.6924542222466, 33.1036905220286,
+ 33.5195630181606, 33.9401201338504, 34.3654107808513, 34.7954843644001,
+ 35.2303907882032, 35.6701804594619, 36.1149042939698, 36.5646137212482,
+ 37.0193606897411, 37.4791976720634, 37.944177670299, 38.4143542213633,
+ 38.8897814024065, 39.3705138362898, 39.8566066971106, 40.3481157157767,
+ 40.8450971856484, 41.3476079682522, 41.8557054990105, 42.369447793091,
+ 42.8888934512647, 43.4141016658423, 43.9451322266965, 44.4820455273072,
+ 45.0249025708978, 45.57376497661, 46.128694985791, 46.6897554682848,
+ 47.257009928828, 47.8305225135037, 48.4103580162663, 48.9965818855272,
+ 49.589260230802, 50.1884598294566, 50.794248133489, 51.4066932764077,
+ 52.0258640801652, 52.6518300621766, 53.2846614424041, 53.9244291505136,
+ 54.5712048331156, 55.2250608610794, 55.8860703369173, 56.5543071022513,
+ 57.2298457453516, 57.9127616087739, 58.6031307970611, 59.3010301845114,
+ 60.0065374230609, 60.7197309502355, 61.4406899971675, 62.1694945967356,
+ 62.9062255917496, 63.6509646432403, 64.4037942388625, 65.1647977013236,
+ 65.9340591969731, 66.7116637444152, 67.4976972232724, 68.2922463830112,
+ 69.0953988518382, 69.9072431457598, 70.7278686776501, 71.5573657664994,
+ 72.3958256466906, 73.2433404774142, 74.1000033521872, 74.9659083084248,
+ 75.8411503371909, 76.7258253929696, 77.6200304036002, 78.5238632802992,
+ 79.4374229277768, 80.3608092544678, 81.2941231828966, 82.2374666600933,
+ 83.1909426682048, 84.154655235138, 85.1287094453491, 86.1132114507694,
+ 87.108268481825, 88.1139888585565, 89.1304820019001, 90.1578584450571,
+ 91.1962298449948, 92.2457089940652, 93.3064098317639, 94.3784474565997,
+ 95.4619381380949, 96.5569993289116, 97.6637496771184, 98.7823090385655,
+ 99.9127984894415, 101.055340338899, 102.210058141845, 103.377076711919,
+ 104.556522134513, 105.748521780005, 106.953204317117, 108.170699726403,
+ 109.401139313892, 110.644655724874, 111.901382957862, 113.171456378648,
+ 114.455012734562, 115.752190168864, 117.063128235285, 118.387967912751,
+ 119.726851620228, 121.079923231788, 122.447328091724, 123.829213029981,
+ 125.225726377642, 126.637017982633, 128.063239225529, 129.504543035659,
+ 130.961083907258, 132.43301791588, 133.920502734926, 135.423697652396,
+ 136.942763587828, 138.477863109372, 140.029160451099, 141.596821530472,
+ 143.181013966024, 144.781907095212, 146.399671992475, 148.034481487503,
+ 149.686510183665, 151.355934476676, 153.042932573466, 154.747684511235,
+ 156.470372176717, 158.211179325695, 159.970291602654, 161.747896560765,
+ 163.544183681914, 165.359344397174, 167.193572107279, 169.047062203492,
+ 170.920012088617, 172.812621198221, 174.725091022243, 176.657625126586,
+ 178.610429175187, 180.583710952171, 182.577680384379, 184.59254956399,
+ 186.628532771569, 188.685846499193, 190.764709473972, 192.865342681753,
+ 194.987969391112, 197.13281517763, 199.300107948348, 201.490077966701,
+ 203.702957877374, 205.938982731875, 208.198390014006, 210.481419665809,
+ 212.788314113849, 215.119318295558, 217.474679686168, 219.854648325694,
+ 222.259476846381, 224.689420500319, 227.144737187562, 229.625687484264,
+ 232.132534671514, 234.665544764103, 237.224986539876, 239.811131569336,
+ 242.424254245529, 245.064631814346, 247.73254440507, 250.428275061399,
+ 253.152109772633, 255.904337505438, 258.685250235678, 261.49514298094,
+ 264.334313833161, 267.203063991664, 270.101697796781, 273.03052276345,
+ 275.989849615675, 278.979992320954, 282.001268125309, 285.053997588697,
+ 288.138504620796, 291.255116517118, 294.404163995707, 297.585981234071,
+ 300.800905906628, 304.049279222569, 307.331445964095, 310.647754525259,
+ 313.998556950887, 317.384208976364, 320.805070067649, 324.26150346164,
+ 327.753876207298, 331.28255920701, 334.84792725845, 338.450359096983,
+ 342.090237438443, 345.767949022632, 349.483884657022, 353.238439261111,
+ 357.032011911288, 360.865005886229, 364.73782871259, 368.650892211681,
+ 372.604612546163, 376.59941026756, 380.635710364328, 384.713942310386,
+ 388.83454011424, 392.997942368521, 397.20459230049, 401.454937822634,
+ 405.749431584178, 410.088531023082, 414.47269841859, 418.902400944533,
+ 423.378110722949, 427.900304878816, 432.469465594816, 437.086080167171,
+ 441.750641062068, 446.463645972511, 451.225597876033, 456.037005092914,
+ 460.89838134554, 465.81024581748, 470.773123214509, 475.787543825096,
+ 480.854043582649, 485.973164127686, 491.14545287122, 496.371463058725,
+ 501.651753834779, 506.986890308486, 512.377443619739, 517.823991006384,
+ 523.32711587159, 528.887407852831, 534.505462890955, 540.181883300517,
+ 545.917277840779, 551.712261787277, 557.567457004939, 563.48349202123,
+ 569.461002100643, 575.500629320033, 581.603022644652, 587.76883800521,
+ 593.998738375827, 600.29339385279, 606.653481734616, 613.07968660232,
+ 619.572700401503, 626.133222524762, 632.761959895347, 639.459627051767,
+ 646.226946233466, 653.064647467273, 659.973468655012, 666.954155662449,
+ 674.007462408703, 681.134150957274, 688.334991607664, 695.610762988527,
+ 702.962252151562, 710.390254666907, 717.895574719168, 725.479025205175,
+ 733.141427832198, 740.883613218127, 748.706420992262, 756.610699897378,
+ 764.597307893424, 772.667112261926, 780.820989711908, 789.059826487117,
+ 797.384518474445, 805.79597131351, 814.295100508111, 822.882831538009,
+ 831.560099973222, 840.327851588798, 849.187042481472, 858.138639187298,
+ 867.183618801265, 876.322969097945, 885.557688653527, 894.88878696958,
+ 904.317284598324, 913.844213269149, 923.470616016881, 933.197547311661,
+ 943.02607318998, 952.957271387842, 962.99223147528, 973.13205499233,
+ 983.377855587028, 993.730759155025, 1004.19190398011, 1014.7624408779,
+ 1025.44353334027, 1036.23635768138, 1047.14210318612, 1058.16197226031,
+ 1069.29718058216, 1080.54895725615, 1091.91854496832, 1103.40720014439,
+ 1115.01619310819, 1126.74680824381, 1138.60034415848, 1150.57811384819,
+ 1162.68144486462, 1174.91167948465, 1187.27017488269, 1199.75830330268,
+ 1212.37745223534, 1225.12902459516, 1238.01443890053, 1251.03512945689,
+ 1264.19254654015, 1277.48815658428, 1290.92344237023, 1304.49990321753,
+ 1318.21905517769, 1332.0824312314, 1346.09158148618, 1360.24807337821,
+ 1374.55349187613, 1389.00943968636, 1403.61753746281, 1418.37942401772,
+ 1433.29675653564, 1448.37121079053, 1463.60448136459, 1478.99828187054,
+ 1494.55434517686, 1510.27442363459, 1526.16028930875, 1542.21373421151,
+ 1558.43657053802, 1574.8306309066, 1591.39776860023, 1608.13985781215,
+ 1625.05879389502, 1642.15649361107, 1659.43489538767, 1676.89595957601,
+ 1694.54166871017, 1712.37402777397, 1730.39506446684, 1748.60682947636,
+ 1767.01139675239, 1785.61086378491, 1804.40735188573, 1823.40300647457,
+ 1842.59999736598, 1862.00051906422, 1881.60679105712, 1901.42105811765,
+ 1921.44559060702, 1941.68268478254, 1962.13466310849, 1982.80387457295,
+ 2003.69269500608, 2024.80352740423, 2046.13880225813, 2067.70097788409,
+ 2089.4925407609, 2111.51600586931, 2133.77391703832, 2156.2688472933,
+ 2179.00339921048, 2201.98020527506, 2225.20192824396, 2248.67126151315,
+ 2272.39092949114, 2296.36368797505, 2320.59232453288, 2345.07965889086,
+ 2369.82854332463, 2394.84186305701, 2420.1225366596, 2445.67351646045,
+ 2471.4977889564, 2497.5983752314, 2523.97833137945, 2550.64074893434,
+ 2577.58875530317, 2604.8255142071, 2632.35422612708, 2660.17812875505,
+ 2688.30049745283, 2716.72464571406, 2745.45392563483, 2774.49172838938,
+ 2803.84148471127, 2833.50666538283, 2863.49078172885, 2893.79738611828,
+ 2924.43007247227, 2955.39247677789, 2986.68827760926, 3018.32119665627,
+ 3050.29499925996, 3082.61349495315, 3115.28053801072, 3148.30002800544,
+ 3181.67591037289, 3215.41217698172, 3249.51286671181, 3283.98206604386,
+ 3318.8239096497, 3354.04258099714, 3389.64231295962, 3425.62738843341,
+ 3462.00214096588, 3498.770955389, 3535.93826846362, 3573.50856952949,
+ 3611.48640116911, 3649.87635987397, 3688.68309672536, 3727.91131807909,
+ 3767.56578626554, 3807.6513202933, 3848.17279656462, 3889.13514960257,
+ 3930.54337278366, 3972.40251908377, 4014.71770183098, 4057.49409547529,
+ 4100.73693635754, 4144.45152349895, 4188.64321939905, 4233.31745083673,
+ 4278.47970969433, 4324.13555378427, 4370.2906076885, 4416.9505636112,
+ 4464.12118224336, 4511.80829363585, 4560.01779808583, 4608.75566703869,
+ 4658.02794399743, 4707.84074544526, 4758.20026178446, 4809.11275828399,
+ 4860.58457604072, 4912.6221329584, 4965.23192473005, 5018.42052584652,
+ 5072.19459060902, 5126.56085415876, 5181.52613352201, 5237.09732866887,
+ 5293.28142358609, 5350.08548736398, 5407.51667529896, 5465.58223001341,
+ 5524.28948258769, 5583.64585370912, 5643.65885483892, 5704.33608939131,
+ 5765.68525393099, 5827.71413938938, 5890.43063229428, 5953.84271601949,
+ 6017.95847204743, 6082.78608125617, 6148.33382521752, 6214.610087517,
+ 6281.62335509419, 6349.38221959681, 6417.89537875378, 6487.17163777577,
+ 6557.21991076552, 6628.04922215295, 6699.66870814791, 6772.08761821761,
+ 6845.31531658155, 6919.36128372573, 6994.23511794429, 7069.94653689413,
+ 7146.5053791833, 7223.92160596987, 7302.20530258909, 7381.36668020537,
+ 7461.41607748598, 7542.36396229371, 7624.22093341411, 7706.99772229679,
+ 7790.70519482415, 7875.35435311374, 7960.95633733285, 8047.52242755054,
+ 8135.06404560776, 8223.5927570193, 8313.12027290238, 8403.65845193137,
+ 8495.21930231871, 8587.81498382941, 8681.45780982398, 8776.16024932246,
+ 8871.93492910726, 8968.79463585546, 9066.75231829962, 9165.82108941207,
+ 9266.0142286397, 9367.34518415456, 9469.8275751412, 9573.47519411942,
+ 9678.30200930089, 9784.32216698275, 9891.54999396144, 10000
+};
+
}
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/constants.h
--- a/source/common/constants.h Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/constants.h Tue Mar 22 12:41:25 2016 +0530
@@ -100,6 +100,11 @@
extern const double g_YUVtoRGB_BT2020[3][3];
+#define MIN_HDR_LEGAL_RANGE 64
+#define MAX_HDR_LEGAL_RANGE 940
+#define CBCR_OFFSET 512
+extern const double g_ST2084_PQTable[MAX_HDR_LEGAL_RANGE -
MIN_HDR_LEGAL_RANGE + 1];
+
}
#endif
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/loopfilter.cpp
--- a/source/common/loopfilter.cpp Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/loopfilter.cpp Tue Mar 22 12:41:25 2016 +0530
@@ -27,7 +27,6 @@
#include "primitives.h"
#define PIXEL_MIN 0
-#define PIXEL_MAX ((1 << X265_DEPTH) - 1)
namespace {
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/param.cpp
--- a/source/common/param.cpp Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/param.cpp Tue Mar 22 12:41:25 2016 +0530
@@ -247,7 +247,7 @@
param->maxCLL = 0;
param->maxFALL = 0;
param->minLuma = 0;
- param->maxLuma = 0;
+ param->maxLuma = PIXEL_MAX;
}
int x265_param_default_preset(x265_param* param, const char* preset, const
char* tune)
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/picyuv.cpp
--- a/source/common/picyuv.cpp Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/picyuv.cpp Tue Mar 22 12:41:25 2016 +0530
@@ -287,15 +287,17 @@
pixel *U = m_picOrg[1];
pixel *V = m_picOrg[2];
- bool calcHDRParams = !!param.maxLuma || !!param.minLuma ||
!!param.maxCLL;
+#if HIGH_BIT_DEPTH
+ bool calcHDRParams = !!param.minLuma || !!param.maxCLL ||
(param.maxLuma != PIXEL_MAX);
/* Apply min/max luma bounds and calculate max and avg luma levels for
HDR SEI messages */
if (calcHDRParams)
{
X265_CHECK(pic.bitDepth == 10, "HDR stats can be
applied/calculated only for 10bpp content");
- uint64_t sumLuma;
- primitives.calcHDRStats(Y, U, V, m_stride, m_strideC, width,
height, &sumLuma, &m_maxLumaLevel, (pixel)param.minLuma,
(pixel)param.maxLuma, m_hChromaShift, m_vChromaShift);
- m_avgLumaLevel = (double)(sumLuma) / (m_picHeight * m_picWidth);
+ primitives.calcHDRStats(Y, U, V, m_stride, m_strideC, width,
height, &m_avgLumaLevel, &m_maxLumaLevel, (pixel)param.minLuma,
(pixel)param.maxLuma, m_hChromaShift, m_vChromaShift);
}
+#else
+ (void) param;
+#endif
/* extend the right edge if width was not multiple of the minimum CU
size */
for (int r = 0; r < height; r++)
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/pixel.cpp
--- a/source/common/pixel.cpp Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/pixel.cpp Tue Mar 22 12:41:25 2016 +0530
@@ -607,7 +607,6 @@
* s1*s1, s2*s2, and s1*s2 also obtain this value for edge cases:
((2^10-1)*16*4)^2 = 4286582784.
* Maximum value for 9-bit is: ss*64 = (2^9-1)^2*16*4*64 = 1069551616,
which will not overflow. */
-#define PIXEL_MAX ((1 << X265_DEPTH) - 1)
#if HIGH_BIT_DEPTH
X265_CHECK((X265_DEPTH == 10) || (X265_DEPTH == 12), "ssim invalid
depth\n");
#define type float
@@ -873,51 +872,58 @@
}
}
-static void calcHDRStats_c(pixel *srcY, pixel* srcU, pixel* srcV, intptr_t
stride, intptr_t strideC, int width, int height, uint64_t *outsum,
+#if HIGH_BIT_DEPTH
+static void calcHDRStats_c(pixel *srcY, pixel* srcU, pixel* srcV, intptr_t
stride, intptr_t strideC, int width, int height, double *outsum,
pixel *outMax, const pixel minPix, const pixel
maxPix, const int hShift, const int vShift)
{
- pixel maxLumaLevel = 0;
- uint64_t sumLuma = 0;
pixel rgb[3];
+ uint16_t maxRGB = 0, maxLumaLevel = 0;
+ uint64_t rowsumLuma = 0;
+ double rowavgLuma = 0;
+
+ uint16_t minLegal = (uint16_t)MIN_HDR_LEGAL_RANGE, maxLegal =
(uint16_t)MAX_HDR_LEGAL_RANGE;
for (int r = 0; r < height >> vShift; r++)
{
+ rowsumLuma = 0;
for (int c = 0; c < width >> hShift; c++)
{
pixel y = 0, cb = 0, cr = 0;
/* Clip luma of source picture to max and min, only if they
are specified. Average luma values for RGB conversions */
if (!hShift && !vShift) /* YUV444 */
{
- y = srcY[c] = maxPix ? x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[c]) : X265_MAX(minPix, srcY[c]);
+ y = srcY[c] = x265_clip3((pixel)minPix, (pixel)maxPix,
srcY[c]);
cb = srcU[c]; cr = srcV[c];
}
else if (hShift && !vShift) /* YUV422 */
{
- srcY[2*c] = maxPix ? x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[2*c]) : X265_MAX(minPix, srcY[2*c]);
- srcY[2*c + 1] = maxPix ? x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[2*c + 1]) : X265_MAX(minPix, srcY[2*c + 1]);
+ srcY[2*c] = x265_clip3((pixel)minPix, (pixel)maxPix,
srcY[2*c]);
+ srcY[2*c + 1] = x265_clip3((pixel)minPix, (pixel)maxPix,
srcY[2*c + 1]);
y = (srcY[2*c] + srcY[2*c + 1]) >> 1;
cb = srcU[c]; cr = srcV[c];
}
else if (hShift && vShift) /* YUV420 */
{
- srcY[2*c] = maxPix ? x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[2*c]) : X265_MAX(minPix, srcY[2*c]);
- srcY[2*c + 1] = maxPix ? x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[2*c + 1]) : X265_MAX(minPix, srcY[2*c + 1]);
- srcY[stride + 2*c] = maxPix ? x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[stride + 2*c]) : X265_MAX(minPix, srcY[stride + 2*c]);
- srcY[stride + 2*c + 1] = maxPix ?
x265_clip3((pixel)minPix, (pixel)maxPix, srcY[stride + 2*c + 1]) :
X265_MAX(minPix, srcY[stride + 2*c + 1]);
+ srcY[2*c] = x265_clip3((pixel)minPix, (pixel)maxPix,
srcY[2*c]);
+ srcY[2*c + 1] = x265_clip3((pixel)minPix, (pixel)maxPix,
srcY[2*c + 1]);
+ srcY[stride + 2*c] = x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[stride + 2*c]);
+ srcY[stride + 2*c + 1] = x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[stride + 2*c + 1]);
y = (srcY[2*c] + srcY[2*c + 1] + srcY[stride + 2*c] +
srcY[stride + 2*c + 1]) >> 2;
cb = srcU[c]; cr = srcV[c];
}
else if (!strideC) /* YUV400 */
{
- y = srcY[c] = maxPix ? x265_clip3((pixel)minPix,
(pixel)maxPix, srcY[c]) : X265_MAX(minPix, srcY[c]);
+ y = srcY[c] = x265_clip3((pixel)minPix, (pixel)maxPix,
srcY[c]);
cb = cr = 0;
}
/* Rec 2020 Yuv to RGB */
for (int i = 0; i < 3; i++)
- rgb[i] = (pixel) (y * g_YUVtoRGB_BT2020[i][0] + cb *
g_YUVtoRGB_BT2020[i][1] + cr * g_YUVtoRGB_BT2020[i][2]);
+ rgb[i] = (pixel) (y * g_YUVtoRGB_BT2020[i][0] + (cb -
CBCR_OFFSET) * g_YUVtoRGB_BT2020[i][1] + (cr - CBCR_OFFSET) *
g_YUVtoRGB_BT2020[i][2]);
/* maxCLL and maxFALL */
- maxLumaLevel = X265_MAX(maxLumaLevel, X265_MAX(rgb[0],
X265_MAX(rgb[1], rgb[2])));
- sumLuma += maxLumaLevel;
+ maxRGB = X265_MAX(maxRGB, X265_MAX(rgb[0], X265_MAX(rgb[1],
rgb[2])));
+ maxRGB = X265_MIN(X265_MAX(maxRGB, minLegal), maxLegal);
+ maxLumaLevel = (uint16_t) g_ST2084_PQTable[maxRGB - minLegal];
+ rowsumLuma += maxLumaLevel;
}
srcY += stride << vShift;
if (strideC)
@@ -925,11 +931,12 @@
srcU += strideC;
srcV += strideC;
}
+ rowavgLuma += ((double)rowsumLuma / width);
}
- *outsum = sumLuma;
+ *outsum = rowavgLuma / height;
*outMax = maxLumaLevel;
}
-
+#endif
} // end anonymous namespace
namespace X265_NS {
@@ -1214,7 +1221,9 @@
p.planecopy_cp = planecopy_cp_c;
p.planecopy_sp = planecopy_sp_c;
p.planecopy_sp_shl = planecopy_sp_shl_c;
+#if HIGH_BIT_DEPTH
p.calcHDRStats = calcHDRStats_c;
+#endif
p.propagateCost = estimateCUPropagateCost;
}
}
diff -r 2de6cb99313a -r 2860b4d8bd68 source/common/primitives.h
--- a/source/common/primitives.h Mon Mar 21 13:50:14 2016 +0530
+++ b/source/common/primitives.h Tue Mar 22 12:41:25 2016 +0530
@@ -185,7 +185,7 @@
typedef void (*sign_t)(int8_t *dst, const pixel *src1, const pixel *src2,
const int endX);
typedef void (*planecopy_cp_t) (const uint8_t* src, intptr_t srcStride,
pixel* dst, intptr_t dstStride, int width, int height, int shift);
typedef void (*planecopy_sp_t) (const uint16_t* src, intptr_t srcStride,
pixel* dst, intptr_t dstStride, int width, int height, int shift, uint16_t
mask);
-typedef void (*calcHDRStats_t)(pixel *srcY, pixel* srcU, pixel* srcV,
intptr_t stride, intptr_t strideC, int width, int height, uint64_t *outsum,
pixel *outMax, const pixel minPix, const pixel maxPix, const int hShift,
const int vShift);
+typedef void (*calcHDRStats_t)(pixel *srcY, pixel* srcU, pixel* srcV,
intptr_t stride, intptr_t strideC, int width, int height, double *outsum,
pixel *outMax, const pixel minPix, const pixel maxPix, const int hShift,
const int vShift);
typedef void (*cutree_propagate_cost) (int* dst, const uint16_t*
propagateIn, const int32_t* intraCosts, const uint16_t* interCosts, const
int32_t* invQscales, const double* fpsFactor, int len);
diff -r 2de6cb99313a -r 2860b4d8bd68 source/test/testharness.h
--- a/source/test/testharness.h Mon Mar 21 13:50:14 2016 +0530
+++ b/source/test/testharness.h Tue Mar 22 12:41:25 2016 +0530
@@ -32,7 +32,6 @@
#pragma warning(disable: 4324) // structure was padded due to
__declspec(align())
#endif
-#define PIXEL_MAX ((1 << X265_DEPTH) - 1)
#define PIXEL_MIN 0
#define SHORT_MAX 32767
#define SHORT_MIN -32767
--
Deepthi Nandakumar
Engineering Manager, x265
Multicoreware, Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160324/b492959d/attachment-0001.html>
More information about the x265-devel
mailing list