A method of encoding, comprising: receiving an input video signal comprising input video content in an input color space; converting (108, 128) the input video content in the input color space to XYZ video content in an XYZ color space; encoding (114, 134) luma values in the XYZ video content into perceptually quantized luma values in a PQ color space; downsampling (110, 130) chroma values in the XYZ video content into downsampled XYZ video content in the XYZ color space; generating (118, 138), based on a combination of the PQ luma values and the downsampled XYZ video content, Y'DzDx video content in an Y'DzDx color space; wherein the method is performed by one or more computing devices, further comprising applying a color gamut reshaping function to at least one of the XYZ video content, or the Y'DzDx video content to reshape a color gamut or a portion thereof of the at least one of the XYZ video content, or the Y'DzDx video content in the XYZ colour space or the Y'DzDx colour space, respectively, wherein the color gamut reshaping function is generated by performing: determining a center point at a color gamut of the video content to be reshaped; identifying an outer boundary of the color gamut to be reshaped; determining, for each boundary point at the outer boundary of the color gamut to be reshaped, a first distance and first angle from the center point to the respective boundary point of the color gamut to be reshaped; determining, for each boundary point at the outer boundary of the color gamut to be reshaped, a second distance and second angle from the center point to a respective boundary point of an outer boundary of the XYZ or Y'DzDx code word space, respectively, in which the color gamut to be reshaped is defined, which respective boundary point of the outer boundary of the XYZ or Y'DzDx code word space, respectively, lies on a same line stretching radially from the center point through the respective boundary point on the outer boundary of the color gamut; determining, for each boundary point at the outer boundary of the color gamut to be reshaped, an angle-dependent scaling ratio as a ratio between the second distance and the first distance; generating the color gamut reshaping function as comprising the second angles and the corresponding angle-dependent scaling ratios computed based on the first distances and the second distances. receiving an input video signal comprising input video content in an input color space; converting (108, 128) the input video content in the input color space to XYZ video content in an XYZ color space; encoding (114, 134) luma values in the XYZ video content into perceptually quantized luma values in a PQ color space; downsampling (110, 130) chroma values in the XYZ video content into downsampled XYZ video content in the XYZ color space; generating (118, 138), based on a combination of the PQ luma values and the downsampled XYZ video content, Y'DzDx video content in an Y'DzDx color space; wherein the method is performed by one or more computing devices, determining a center point at a color gamut of the video content to be reshaped; identifying an outer boundary of the color gamut to be reshaped; determining, for each boundary point at the outer boundary of the color gamut to be reshaped, a first distance and first angle from the center point to the respective boundary point of the color gamut to be reshaped; determining, for each boundary point at the outer boundary of the color gamut to be reshaped, a second distance and second angle from the center point to a respective boundary point of an outer boundary of the XYZ or Y'DzDx code word space, respectively, in which the color gamut to be reshaped is defined, which respective boundary point of the outer boundary of the XYZ or Y'DzDx code word space, respectively, lies on a same line stretching radially from the center point through the respective boundary point on the outer boundary of the color gamut; determining, for each boundary point at the outer boundary of the color gamut to be reshaped, an angle-dependent scaling ratio as a ratio between the second distance and the first distance; generating the color gamut reshaping function as comprising the second angles and the corresponding angle-dependent scaling ratios computed based on the first distances and the second distances.