private void build_bg_ycc_rgb_table()
{
/* Wide gamut case, bg-sYCC */
m_Cr_r_tab = new int[JpegConstants.MAXJSAMPLE + 1];
m_Cb_b_tab = new int[JpegConstants.MAXJSAMPLE + 1];
m_Cr_g_tab = new int[JpegConstants.MAXJSAMPLE + 1];
m_Cb_g_tab = new int[JpegConstants.MAXJSAMPLE + 1];
for (int i = 0, x = -JpegConstants.CENTERJSAMPLE; i <= JpegConstants.MAXJSAMPLE; i++, x++)
{
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 2.804 * x */
m_Cr_r_tab[i] = JpegUtils.RIGHT_SHIFT(FIX(2.804) * x + ONE_HALF, SCALEBITS);
/* Cb=>B value is nearest int to 3.544 * x */
m_Cb_b_tab[i] = JpegUtils.RIGHT_SHIFT(FIX(3.544) * x + ONE_HALF, SCALEBITS);
/* Cr=>G value is scaled-up -1.428272572 * x */
m_Cr_g_tab[i] = (-FIX(1.428272572)) * x;
/* Cb=>G value is scaled-up -0.688272572 * x */
/* We also add in ONE_HALF so that need not do it in inner loop */
m_Cb_g_tab[i] = (-FIX(0.688272572)) * x + ONE_HALF;
}
}