Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: source/row_gcc.cc

Issue 1359443005: move constants into common (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: fix up jpeg comments and remove todo to move to common Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/row_common.cc ('k') | source/row_neon.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // VERSION 2 1 // VERSION 2
2 /* 2 /*
3 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license 5 * Use of this source code is governed by a BSD-style license
6 * that can be found in the LICENSE file in the root of the source 6 * that can be found in the LICENSE file in the root of the source
7 * tree. An additional intellectual property rights grant can be found 7 * tree. An additional intellectual property rights grant can be found
8 * in the file PATENTS. All contributing project authors may 8 * in the file PATENTS. All contributing project authors may
9 * be found in the AUTHORS file in the root of the source tree. 9 * be found in the AUTHORS file in the root of the source tree.
10 */ 10 */
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 "m"(kRGBAToV), // %5 1312 "m"(kRGBAToV), // %5
1313 "m"(kRGBAToU), // %6 1313 "m"(kRGBAToU), // %6
1314 "m"(kAddUV128) // %7 1314 "m"(kAddUV128) // %7
1315 : "memory", "cc", NACL_R14 1315 : "memory", "cc", NACL_R14
1316 "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" 1316 "xmm0", "xmm1", "xmm2", "xmm6", "xmm7"
1317 ); 1317 );
1318 } 1318 }
1319 1319
1320 #if defined(HAS_I422TOARGBROW_SSSE3) || defined(HAS_I422TOARGBROW_AVX2) 1320 #if defined(HAS_I422TOARGBROW_SSSE3) || defined(HAS_I422TOARGBROW_AVX2)
1321 1321
1322 // BT.601 YUV to RGB reference
1323 // R = (Y - 16) * 1.164 - V * -1.596
1324 // G = (Y - 16) * 1.164 - U * 0.391 - V * 0.813
1325 // B = (Y - 16) * 1.164 - U * -2.018
1326
1327 // Y contribution to R,G,B. Scale and bias.
1328 // TODO(fbarchard): Consider moving constants into a common header.
1329 #define YG 18997 /* round(1.164 * 64 * 256 * 256 / 257) */
1330 #define YGB -1160 /* 1.164 * 64 * -16 + 64 / 2 */
1331
1332 // U and V contributions to R,G,B.
1333 #define UB -128 /* max(-128, round(-2.018 * 64)) */
1334 #define UG 25 /* round(0.391 * 64) */
1335 #define VG 52 /* round(0.813 * 64) */
1336 #define VR -102 /* round(-1.596 * 64) */
1337
1338 // Bias values to subtract 16 from Y and 128 from U and V.
1339 #define BB (UB * 128 + YGB)
1340 #define BG (UG * 128 + VG * 128 + YGB)
1341 #define BR (VR * 128 + YGB)
1342
1343 // BT601 constants for YUV to RGB.
1344 YuvConstants SIMD_ALIGNED(kYuvConstants) = {
1345 { UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0,
1346 UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 },
1347 { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG,
1348 UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG },
1349 { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR,
1350 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR },
1351 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB },
1352 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG },
1353 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR },
1354 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG }
1355 };
1356
1357 // BT601 constants for NV21 where chroma plane is VU instead of UV.
1358 YuvConstants SIMD_ALIGNED(kYvuConstants) = {
1359 { 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB,
1360 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB },
1361 { VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG,
1362 VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG },
1363 { VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0,
1364 VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 },
1365 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB },
1366 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG },
1367 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR },
1368 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG }
1369 };
1370
1371 #undef YG
1372 #undef YGB
1373 #undef UB
1374 #undef UG
1375 #undef VG
1376 #undef VR
1377 #undef BB
1378 #undef BG
1379 #undef BR
1380
1381 // JPEG YUV to RGB reference
1382 // * R = Y - V * -1.40200
1383 // * G = Y - U * 0.34414 - V * 0.71414
1384 // * B = Y - U * -1.77200
1385
1386 // Y contribution to R,G,B. Scale and bias.
1387 // TODO(fbarchard): Consider moving constants into a common header.
1388 #define YGJ 16320 /* round(1.000 * 64 * 256 * 256 / 257) */
1389 #define YGBJ 32 /* 64 / 2 */
1390
1391 // U and V contributions to R,G,B.
1392 #define UBJ -113 /* round(-1.77200 * 64) */
1393 #define UGJ 22 /* round(0.34414 * 64) */
1394 #define VGJ 46 /* round(0.71414 * 64) */
1395 #define VRJ -90 /* round(-1.40200 * 64) */
1396
1397 // Bias values to subtract 16 from Y and 128 from U and V.
1398 #define BBJ (UBJ * 128 + YGBJ)
1399 #define BGJ (UGJ * 128 + VGJ * 128 + YGBJ)
1400 #define BRJ (VRJ * 128 + YGBJ)
1401
1402 // JPEG constants for YUV to RGB.
1403 YuvConstants SIMD_ALIGNED(kYuvJConstants) = {
1404 { UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0,
1405 UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0 },
1406 { UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ,
1407 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ,
1408 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ,
1409 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ },
1410 { 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ,
1411 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ },
1412 { BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ,
1413 BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ },
1414 { BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ,
1415 BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ },
1416 { BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ,
1417 BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ },
1418 { YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ,
1419 YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ }
1420 };
1421
1422 #undef YGJ
1423 #undef YGBJ
1424 #undef UBJ
1425 #undef UGJ
1426 #undef VGJ
1427 #undef VRJ
1428 #undef BBJ
1429 #undef BGJ
1430 #undef BRJ
1431
1432 // BT.709 YUV to RGB reference
1433 // * R = Y - V * -1.28033
1434 // * G = Y - U * 0.21482 - V * 0.38059
1435 // * B = Y - U * -2.12798
1436
1437 // Y contribution to R,G,B. Scale and bias.
1438 // TODO(fbarchard): Consider moving constants into a common header.
1439 #define YGH 16320 /* round(1.000 * 64 * 256 * 256 / 257) */
1440 #define YGBH 32 /* 64 / 2 */
1441
1442 // U and V contributions to R,G,B.
1443 #define UBH -128 /* max(-128, round(-2.12798 * 64)) */
1444 #define UGH 14 /* round(0.21482 * 64) */
1445 #define VGH 24 /* round(0.38059 * 64) */
1446 #define VRH -82 /* round(-1.28033 * 64) */
1447
1448 // Bias values to round, and subtract 128 from U and V.
1449 #define BBH (UBH * 128 + YGBH)
1450 #define BGH (UGH * 128 + VGH * 128 + YGBH)
1451 #define BRH (VRH * 128 + YGBH)
1452
1453 // BT.709 constants for YUV to RGB.
1454 YuvConstants SIMD_ALIGNED(kYuvHConstants) = {
1455 { UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0,
1456 UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0 },
1457 { UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH,
1458 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH,
1459 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH,
1460 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH },
1461 { 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH,
1462 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH },
1463 { BBH, BBH, BBH, BBH, BBH, BBH, BBH, BBH,
1464 BBH, BBH, BBH, BBH, BBH, BBH, BBH, BBH },
1465 { BGH, BGH, BGH, BGH, BGH, BGH, BGH, BGH,
1466 BGH, BGH, BGH, BGH, BGH, BGH, BGH, BGH },
1467 { BRH, BRH, BRH, BRH, BRH, BRH, BRH, BRH,
1468 BRH, BRH, BRH, BRH, BRH, BRH, BRH, BRH },
1469 { YGH, YGH, YGH, YGH, YGH, YGH, YGH, YGH,
1470 YGH, YGH, YGH, YGH, YGH, YGH, YGH, YGH }
1471 };
1472
1473 #undef YGH
1474 #undef YGBH
1475 #undef UBH
1476 #undef UGH
1477 #undef VGH
1478 #undef VRH
1479 #undef BBH
1480 #undef BGH
1481 #undef BRH
1482
1483 // Read 8 UV from 411 1322 // Read 8 UV from 411
1484 #define READYUV444 \ 1323 #define READYUV444 \
1485 "movq " MEMACCESS([u_buf]) ",%%xmm0 \n" \ 1324 "movq " MEMACCESS([u_buf]) ",%%xmm0 \n" \
1486 MEMOPREG(movq, 0x00, [u_buf], [v_buf], 1, xmm1) \ 1325 MEMOPREG(movq, 0x00, [u_buf], [v_buf], 1, xmm1) \
1487 "lea " MEMLEA(0x8, [u_buf]) ",%[u_buf] \n" \ 1326 "lea " MEMLEA(0x8, [u_buf]) ",%[u_buf] \n" \
1488 "punpcklbw %%xmm1,%%xmm0 \n" 1327 "punpcklbw %%xmm1,%%xmm0 \n"
1489 1328
1490 // Read 4 UV from 422, upsample to 8 UV 1329 // Read 4 UV from 422, upsample to 8 UV
1491 #define READYUV422 \ 1330 #define READYUV422 \
1492 "movd " MEMACCESS([u_buf]) ",%%xmm0 \n" \ 1331 "movd " MEMACCESS([u_buf]) ",%%xmm0 \n" \
(...skipping 3884 matching lines...) Expand 10 before | Expand all | Expand 10 after
5377 ); 5216 );
5378 } 5217 }
5379 #endif // HAS_ARGBLUMACOLORTABLEROW_SSSE3 5218 #endif // HAS_ARGBLUMACOLORTABLEROW_SSSE3
5380 5219
5381 #endif // defined(__x86_64__) || defined(__i386__) 5220 #endif // defined(__x86_64__) || defined(__i386__)
5382 5221
5383 #ifdef __cplusplus 5222 #ifdef __cplusplus
5384 } // extern "C" 5223 } // extern "C"
5385 } // namespace libyuv 5224 } // namespace libyuv
5386 #endif 5225 #endif
OLDNEW
« no previous file with comments | « source/row_common.cc ('k') | source/row_neon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698