A method for a computing device with a video encoder or image encoder, the method comprising: encoding video in a sequence, including switching color spaces spatially and/or temporally between at least some units of the video within the sequence during the encoding, the color spaces including an RGB-type color space and a YCoCg color space, wherein the encoding comprises prediction of sample values of a current unit of the video based at least in part on sample values of previously-reconstructed content; and outputting encoded data in a bitstream, the encoded data including one or more signals indicating how the color spaces switch between the at least some units of the video within the sequence; the method being characterized in that the sample values of the previously reconstructed content are in a first color space of the color spaces and the sample values of the current unit are in a second, different color space of the color spaces, and in that the prediction includes: converting the sample values of the previously reconstructed content from the first color space to the second color space; predicting the sample values of the current unit using the converted sample values of the previously reconstructed content; reconstructing the sample values of the current unit based at least in part on the predicted sample values of the current unit; converting the reconstructed sample values of the current unit from the second color space to the first color space; and storing the converted reconstructed sample values of the current unit as part of the previously reconstructed content; wherein each converting step (1632, 1672) comprises, for lossy coding, using color space conversion operations to switch between the color spaces, or, for lossless coding, using invertible color space conversion operations and an increased intermediate bit depth to switch between the color spaces; and wherein the encoding includes deblocking previously reconstructed content according to one or more rules, including adjusting strength of a deblocking filter depending on whether either of the primary color components of two adjacent blocks have non-zero residual values. encoding video in a sequence, including switching color spaces spatially and/or temporally between at least some units of the video within the sequence during the encoding, the color spaces including an RGB-type color space and a YCoCg color space, wherein the encoding comprises prediction of sample values of a current unit of the video based at least in part on sample values of previously-reconstructed content; and outputting encoded data in a bitstream, the encoded data including one or more signals indicating how the color spaces switch between the at least some units of the video within the sequence; the method being characterized in that the sample values of the previously reconstructed content are in a first color space of the color spaces and the sample values of the current unit are in a second, different color space of the color spaces, and in that the prediction includes: converting the sample values of the previously reconstructed content from the first color space to the second color space; predicting the sample values of the current unit using the converted sample values of the previously reconstructed content; reconstructing the sample values of the current unit based at least in part on the predicted sample values of the current unit; converting the reconstructed sample values of the current unit from the second color space to the first color space; and storing the converted reconstructed sample values of the current unit as part of the previously reconstructed content; wherein each converting step (1632, 1672) comprises, for lossy coding, using color space conversion operations to switch between the color spaces, or, for lossless coding, using invertible color space conversion operations and an increased intermediate bit depth to switch between the color spaces; and wherein the encoding includes deblocking previously reconstructed content according to one or more rules, including adjusting strength of a deblocking filter depending on whether either of the primary color components of two adjacent blocks have non-zero residual values. converting the sample values of the previously reconstructed content from the first color space to the second color space; predicting the sample values of the current unit using the converted sample values of the previously reconstructed content; reconstructing the sample values of the current unit based at least in part on the predicted sample values of the current unit; converting the reconstructed sample values of the current unit from the second color space to the first color space; and storing the converted reconstructed sample values of the current unit as part of the previously reconstructed content; wherein each converting step (1632, 1672) comprises, for lossy coding, using color space conversion operations to switch between the color spaces, or, for lossless coding, using invertible color space conversion operations and an increased intermediate bit depth to switch between the color spaces; and wherein the encoding includes deblocking previously reconstructed content according to one or more rules, including adjusting strength of a deblocking filter depending on whether either of the primary color components of two adjacent blocks have non-zero residual values.