diff --git a/vp9/common/vp9_enums.h b/vp9/common/vp9_enums.h index 768ff2c947e6e0c3417034dace9d887993026fba..1651b905055d743a5afb5a9cbc66ecaf491d99ae 100644 --- a/vp9/common/vp9_enums.h +++ b/vp9/common/vp9_enums.h @@ -76,4 +76,15 @@ typedef enum { ADST_ADST = 3 // ADST in both directions } TX_TYPE; +typedef enum { + UNKNOWN = 0, + BT_601 = 1, // YUV + BT_709 = 2, // YUV + SMPTE_170 = 3, // YUV + SMPTE_240 = 4, // YUV + RESERVED_1 = 5, + RESERVED_2 = 6, + SRGB = 7 // RGB +} COLOR_SPACE; + #endif // VP9_COMMON_VP9_ENUMS_H_ diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 603c996b2a7129107c29f1760f687604d5a69d7f..704469e29197b6795f25be0dbbffe7ecfe985367 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -90,6 +90,8 @@ typedef struct VP9Common { DECLARE_ALIGNED(16, int16_t, a_dequant[QINDEX_RANGE][8]); #endif + COLOR_SPACE color_space; + int width; int height; int display_width; diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index d4dcfbc1aec53b7dffe6803ee1abbd32d9b81889..601168ef176ac32dcc5fe1f0a138cfe0ef95368a 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -898,12 +898,10 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi, cm->error_resilient_mode = vp9_rb_read_bit(rb); if (cm->frame_type == KEY_FRAME) { - int csp; - check_sync_code(cm, rb); - csp = vp9_rb_read_literal(rb, 3); // colorspace - if (csp != 7) { // != sRGB + cm->color_space = vp9_rb_read_literal(rb, 3); // colorspace + if (cm->color_space != SRGB) { vp9_rb_read_bit(rb); // [16,235] (including xvycc) vs [0,255] range if (cm->version == 1) { cm->subsampling_x = vp9_rb_read_bit(rb); diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index b0cfee3c4c0c1e1f6cbc398bb685abe015063f7b..e727783b3e5406edfa99eb8762d5352f45f7993a 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -1318,18 +1318,10 @@ static void write_uncompressed_header(VP9_COMP *cpi, vp9_wb_write_bit(wb, cm->error_resilient_mode); if (cm->frame_type == KEY_FRAME) { + const COLOR_SPACE cs = UNKNOWN; write_sync_code(wb); - // colorspaces - // 000 - Unknown - // 001 - BT.601 - // 010 - BT.709 - // 011 - SMPTE-170 - // 100 - SMPTE-240 - // 101 - Reserved - // 110 - Reserved - // 111 - sRGB (RGB) - vp9_wb_write_literal(wb, 0, 3); - if (1 /* colorspace != sRGB */) { + vp9_wb_write_literal(wb, cs, 3); + if (cs != SRGB) { vp9_wb_write_bit(wb, 0); // 0: [16, 235] (i.e. xvYCC), 1: [0, 255] if (cm->version == 1) { vp9_wb_write_bit(wb, cm->subsampling_x);