void compute_ideal_colors_and_weights_2planes(
	const block_size_descriptor& bsd,
	const image_block& blk,
	const error_weight_block& ewb,
	unsigned int plane2_component,
	endpoints_and_weights& ei1,
	endpoints_and_weights& ei2
) {
	const auto& pi = bsd.get_partition_info(1, 0);
	bool uses_alpha = !blk.is_constant_channel(3);

	assert(plane2_component < BLOCK_MAX_COMPONENTS);
	switch (plane2_component)
	{
	case 0: // Separate weights for red
		if (uses_alpha)
		{
			compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 0);
		}
		else
		{
			compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 1, 2);
		}
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 0);
		break;

	case 1: // Separate weights for green
		if (uses_alpha)
		{
			compute_ideal_colors_and_weights_3_comp(bsd,blk, ewb,  pi, ei1, 1);
		}
		else
		{
			compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 2);
		}
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 1);
		break;

	case 2: // Separate weights for blue
		if (uses_alpha)
		{
			compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 2);
		}
		else
		{
			compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 1);
		}
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 2);
		break;

	default: // Separate weights for alpha
		assert(uses_alpha);
		compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 3);
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 3);
		break;
	}
}
void compute_ideal_colors_and_weights_2planes(
	const block_size_descriptor& bsd,
	const image_block& blk,
	const error_weight_block& ewb,
	unsigned int plane2_component,
	endpoints_and_weights& ei1,
	endpoints_and_weights& ei2
) {
	const auto& pi = bsd.get_partition_info(1, 0);
	bool uses_alpha = !blk.is_constant_channel(3);

	assert(plane2_component < BLOCK_MAX_COMPONENTS);
	switch (plane2_component)
	{
	case 0:  
		if (uses_alpha)
		{
			compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 0);
		}
		else
		{
			compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 1, 2);
		}
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 0);
		break;

	case 1:  
		if (uses_alpha)
		{
			compute_ideal_colors_and_weights_3_comp(bsd,blk, ewb,  pi, ei1, 1);
		}
		else
		{
			compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 2);
		}
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 1);
		break;

	case 2:  
		if (uses_alpha)
		{
			compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 2);
		}
		else
		{
			compute_ideal_colors_and_weights_2_comp(bsd, blk, ewb, pi, ei1, 0, 1);
		}
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 2);
		break;

	default:  
		assert(uses_alpha);
		compute_ideal_colors_and_weights_3_comp(bsd, blk, ewb, pi, ei1, 3);
		compute_ideal_colors_and_weights_1_comp(bsd, blk, ewb, pi, ei2, 3);
		break;
	}
}