@@ -1439,31 +1439,31 @@ MOS_STATUS VpL0FcFilter::GenerateProcampCscMatrix(VPHAL_CSPACE srcColorSpace, VP
1439
1439
1440
1440
if (IS_COLOR_SPACE_RGB (dstColorSpace) && !IS_COLOR_SPACE_RGB (srcColorSpace))
1441
1441
{
1442
- KernelDll_GetCSCMatrix ( srcColorSpace, dstColorSpace, backCscMatrix);
1442
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( srcColorSpace, dstColorSpace, backCscMatrix) );
1443
1443
bBackCscEnabled = true ; // YUV -> RGB
1444
1444
}
1445
1445
else if (IS_COLOR_SPACE_RGB (srcColorSpace) && !IS_COLOR_SPACE_RGB (dstColorSpace))
1446
1446
{
1447
- KernelDll_GetCSCMatrix ( srcColorSpace, dstColorSpace, preCscMatrix);
1447
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( srcColorSpace, dstColorSpace, preCscMatrix) );
1448
1448
bPreCscEnabled = true ; // RGB -> YUV
1449
1449
}
1450
1450
else if (IS_COLOR_SPACE_BT709_RGB (srcColorSpace) && IS_COLOR_SPACE_BT709_RGB (dstColorSpace))
1451
1451
{
1452
- KernelDll_GetCSCMatrix ( srcColorSpace, CSpace_BT709, preCscMatrix);
1453
- KernelDll_GetCSCMatrix ( CSpace_BT709, dstColorSpace, backCscMatrix);
1452
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( srcColorSpace, CSpace_BT709, preCscMatrix) );
1453
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( CSpace_BT709, dstColorSpace, backCscMatrix) );
1454
1454
bPreCscEnabled = bBackCscEnabled = true ; // 8bit RGB -> RGB
1455
1455
}
1456
1456
else if (IS_COLOR_SPACE_BT2020_RGB (srcColorSpace) && IS_COLOR_SPACE_BT2020_RGB (dstColorSpace))
1457
1457
{
1458
- KernelDll_GetCSCMatrix ( srcColorSpace, CSpace_BT2020, preCscMatrix);
1459
- KernelDll_GetCSCMatrix ( CSpace_BT2020, dstColorSpace, backCscMatrix);
1458
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( srcColorSpace, CSpace_BT2020, preCscMatrix) );
1459
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( CSpace_BT2020, dstColorSpace, backCscMatrix) );
1460
1460
bPreCscEnabled = bBackCscEnabled = true ; // 10bit RGB -> RGB
1461
1461
}
1462
1462
else
1463
1463
{
1464
1464
if (srcColorSpace != dstColorSpace)
1465
1465
{
1466
- KernelDll_GetCSCMatrix ( srcColorSpace, dstColorSpace, preCscMatrix);
1466
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( srcColorSpace, dstColorSpace, preCscMatrix) );
1467
1467
bPreCscEnabled = true ; // YUV -> YUV
1468
1468
VP_PUBLIC_NORMALMESSAGE (" YUV to YUV colorspace. Need pre csc matrix." );
1469
1469
}
@@ -1474,8 +1474,6 @@ MOS_STATUS VpL0FcFilter::GenerateProcampCscMatrix(VPHAL_CSPACE srcColorSpace, VP
1474
1474
}
1475
1475
1476
1476
// Calculate procamp parameters
1477
- // BT2020 is [0, 1023], BT709 is [0, 255], BT2020 need * 4.
1478
- int coefficient = IS_COLOR_SPACE_BT2020 (dstColorSpace) ? 4 : 1 ;
1479
1477
float brightness, contrast, hue, saturation;
1480
1478
brightness = procampParams.fBrightness ;
1481
1479
contrast = procampParams.fContrast ;
@@ -1493,15 +1491,15 @@ MOS_STATUS VpL0FcFilter::GenerateProcampCscMatrix(VPHAL_CSPACE srcColorSpace, VP
1493
1491
procampMatrix[0 ] = contrast;
1494
1492
procampMatrix[1 ] = 0 .0f ;
1495
1493
procampMatrix[2 ] = 0 .0f ;
1496
- procampMatrix[3 ] = 16 .0f * coefficient - 16 .0f * coefficient * contrast + brightness;
1494
+ procampMatrix[3 ] = ( 16 .0f - 16 .0f * contrast + brightness) / 255 . f ;
1497
1495
procampMatrix[4 ] = 0 .0f ;
1498
1496
procampMatrix[5 ] = (float )cos (hue) * contrast * saturation;
1499
1497
procampMatrix[6 ] = (float )sin (hue) * contrast * saturation;
1500
- procampMatrix[7 ] = 128 .0f * coefficient * (1 .0f - procampMatrix[5 ] - procampMatrix[6 ]);
1498
+ procampMatrix[7 ] = ( 128 .0f * (1 .0f - procampMatrix[5 ] - procampMatrix[6 ])) / 255 . f ;
1501
1499
procampMatrix[8 ] = 0 .0f ;
1502
1500
procampMatrix[9 ] = -procampMatrix[6 ];
1503
1501
procampMatrix[10 ] = procampMatrix[5 ];
1504
- procampMatrix[11 ] = 128 .0f * coefficient * (1 .0f - procampMatrix[5 ] + procampMatrix[6 ]);
1502
+ procampMatrix[11 ] = ( 128 .0f * (1 .0f - procampMatrix[5 ] + procampMatrix[6 ])) / 255 . f ;
1505
1503
1506
1504
// Calculate final CSC matrix [backcsc] * [pa] * [precsc]
1507
1505
if (bPreCscEnabled)
@@ -1516,7 +1514,7 @@ MOS_STATUS VpL0FcFilter::GenerateProcampCscMatrix(VPHAL_CSPACE srcColorSpace, VP
1516
1514
}
1517
1515
1518
1516
// Use the output matrix copy into csc matrix to generate kernel CSC parameters
1519
- MOS_SecureMemcpy (cscMatrix, sizeof (float ) * 12 , (void *)procampMatrix, sizeof (float )* 12 );
1517
+ MOS_SecureMemcpy (cscMatrix, sizeof (float ) * 12 , (void *)procampMatrix, sizeof (float ) * 12 );
1520
1518
return MOS_STATUS_SUCCESS;
1521
1519
}
1522
1520
@@ -1537,26 +1535,17 @@ MOS_STATUS VpL0FcFilter::ConvertProcampAndCscToKrnParam(VPHAL_CSPACE srcColorSpa
1537
1535
return MOS_STATUS_SUCCESS;
1538
1536
}
1539
1537
1540
- KernelDll_GetCSCMatrix ( srcColorSpace, dstColorSpace, cscMatrix);
1538
+ VP_PUBLIC_CHK_STATUS_RETURN ( VpUtils::GetNormalizedCSCMatrix ( srcColorSpace, dstColorSpace, cscMatrix) );
1541
1539
}
1542
1540
1543
1541
// Save finalMatrix into csc
1544
1542
VP_PUBLIC_CHK_STATUS_RETURN (MOS_SecureMemcpy (csc.s0123 , sizeof (csc.s0123 ), &cscMatrix[0 ], sizeof (float ) * 3 ));
1545
1543
VP_PUBLIC_CHK_STATUS_RETURN (MOS_SecureMemcpy (csc.s4567 , sizeof (csc.s4567 ), &cscMatrix[4 ], sizeof (float ) * 3 ));
1546
1544
VP_PUBLIC_CHK_STATUS_RETURN (MOS_SecureMemcpy (csc.s89AB , sizeof (csc.s89AB ), &cscMatrix[8 ], sizeof (float ) * 3 ));
1545
+ csc.sCDEF [0 ] = cscMatrix[3 ];
1546
+ csc.sCDEF [1 ] = cscMatrix[7 ];
1547
+ csc.sCDEF [2 ] = cscMatrix[11 ];
1547
1548
1548
- if (IS_COLOR_SPACE_BT2020 (dstColorSpace))
1549
- {
1550
- csc.sCDEF [0 ] = cscMatrix[3 ] / 1023 ;
1551
- csc.sCDEF [1 ] = cscMatrix[7 ] / 1023 ;
1552
- csc.sCDEF [2 ] = cscMatrix[11 ] / 1023 ;
1553
- }
1554
- else
1555
- {
1556
- csc.sCDEF [0 ] = cscMatrix[3 ] / 255 ;
1557
- csc.sCDEF [1 ] = cscMatrix[7 ] / 255 ;
1558
- csc.sCDEF [2 ] = cscMatrix[11 ] / 255 ;
1559
- }
1560
1549
return MOS_STATUS_SUCCESS;
1561
1550
}
1562
1551
0 commit comments