An apparatus for coding video data, comprising: a memory for storing the video data and information about a plurality of coding modes, the video data comprising a plurality of video blocks; and a hardware processor operationally coupled to the memory and configured to: generate a plurality of reconstructed video blocks indicative of a first video block of the plurality of video blocks, the first video block representing one of the plurality of video blocks being provided in a plurality of color spaces, each reconstructed video block being encoded using one of a plurality of coding modes in one of the plurality of color spaces; select one of the plurality of color spaces, the selected color space being the color space that represents the majority of the reconstructed video blocks; apply a color transformation to every reconstructed video block that is not in the selected color space to generate a plurality of reconstructed video blocks that are all in the selected color space; determine a distortion value of each of the plurality of reconstructed video blocks in the selected color space; determine an optimal coding mode based on a cost function and the distortion value for each of the reconstructed video blocks; and encode the first video block of the video data using the determined coding mode. a memory for storing the video data and information about a plurality of coding modes, the video data comprising a plurality of video blocks; and a hardware processor operationally coupled to the memory and configured to: generate a plurality of reconstructed video blocks indicative of a first video block of the plurality of video blocks, the first video block representing one of the plurality of video blocks being provided in a plurality of color spaces, each reconstructed video block being encoded using one of a plurality of coding modes in one of the plurality of color spaces; select one of the plurality of color spaces, the selected color space being the color space that represents the majority of the reconstructed video blocks; apply a color transformation to every reconstructed video block that is not in the selected color space to generate a plurality of reconstructed video blocks that are all in the selected color space; determine a distortion value of each of the plurality of reconstructed video blocks in the selected color space; determine an optimal coding mode based on a cost function and the distortion value for each of the reconstructed video blocks; and encode the first video block of the video data using the determined coding mode. generate a plurality of reconstructed video blocks indicative of a first video block of the plurality of video blocks, the first video block representing one of the plurality of video blocks being provided in a plurality of color spaces, each reconstructed video block being encoded using one of a plurality of coding modes in one of the plurality of color spaces; select one of the plurality of color spaces, the selected color space being the color space that represents the majority of the reconstructed video blocks; apply a color transformation to every reconstructed video block that is not in the selected color space to generate a plurality of reconstructed video blocks that are all in the selected color space; determine a distortion value of each of the plurality of reconstructed video blocks in the selected color space; determine an optimal coding mode based on a cost function and the distortion value for each of the reconstructed video blocks; and encode the first video block of the video data using the determined coding mode. <EOS>