Add a new enum type vpx_color_range_t

to make meaning of color_range obvious.

Change-Id: I303582e448b82b3203b497e27b22601cc718dfff
This commit is contained in:
Yaowu Xu 2015-10-16 16:25:08 -07:00
parent 7dd7a7da20
commit 568429512e
7 changed files with 21 additions and 15 deletions

View File

@ -40,17 +40,17 @@ struct EncodeParameters {
int32_t lossless; int32_t lossless;
int32_t error_resilient; int32_t error_resilient;
int32_t frame_parallel; int32_t frame_parallel;
int32_t color_range; vpx_color_range_t color_range;
vpx_color_space_t cs; vpx_color_space_t cs;
int render_size[2]; int render_size[2];
// TODO(JBB): quantizers / bitrate // TODO(JBB): quantizers / bitrate
}; };
const EncodeParameters kVP9EncodeParameterSet[] = { const EncodeParameters kVP9EncodeParameterSet[] = {
{0, 0, 0, 1, 0, 0, VPX_CS_BT_601}, {0, 0, 0, 1, 0, VPX_CR_STUDIO_RANGE, VPX_CS_BT_601},
{0, 0, 0, 0, 0, 1, VPX_CS_BT_709}, {0, 0, 0, 0, 0, VPX_CR_FULL_RANGE, VPX_CS_BT_709},
{0, 0, 1, 0, 0, 1, VPX_CS_BT_2020}, {0, 0, 1, 0, 0, VPX_CR_FULL_RANGE, VPX_CS_BT_2020},
{0, 2, 0, 0, 1, 0, VPX_CS_UNKNOWN, { 640, 480 }}, {0, 2, 0, 0, 1, VPX_CR_STUDIO_RANGE, VPX_CS_UNKNOWN, { 640, 480 }},
// TODO(JBB): Test profiles (requires more work). // TODO(JBB): Test profiles (requires more work).
}; };

View File

@ -112,7 +112,7 @@ typedef struct BufferPool {
typedef struct VP9Common { typedef struct VP9Common {
struct vpx_internal_error_info error; struct vpx_internal_error_info error;
vpx_color_space_t color_space; vpx_color_space_t color_space;
int color_range; vpx_color_range_t color_range;
int width; int width;
int height; int height;
int render_width; int render_width;

View File

@ -1795,8 +1795,7 @@ static void read_bitdepth_colorspace_sampling(
} }
cm->color_space = vpx_rb_read_literal(rb, 3); cm->color_space = vpx_rb_read_literal(rb, 3);
if (cm->color_space != VPX_CS_SRGB) { if (cm->color_space != VPX_CS_SRGB) {
// [16,235] (including xvycc) vs [0,255] range cm->color_range = (vpx_color_range_t)vpx_rb_read_bit(rb);
cm->color_range = vpx_rb_read_bit(rb);
if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) {
cm->subsampling_x = vpx_rb_read_bit(rb); cm->subsampling_x = vpx_rb_read_bit(rb);
cm->subsampling_y = vpx_rb_read_bit(rb); cm->subsampling_y = vpx_rb_read_bit(rb);
@ -1810,7 +1809,7 @@ static void read_bitdepth_colorspace_sampling(
cm->subsampling_y = cm->subsampling_x = 1; cm->subsampling_y = cm->subsampling_x = 1;
} }
} else { } else {
cm->color_range = 1; cm->color_range = VPX_CR_FULL_RANGE;
if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) {
// Note if colorspace is SRGB then 4:4:4 chroma sampling is assumed. // Note if colorspace is SRGB then 4:4:4 chroma sampling is assumed.
// 4:2:2 or 4:4:0 chroma sampling is not allowed. // 4:2:2 or 4:4:0 chroma sampling is not allowed.
@ -1916,7 +1915,7 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
// specifies that the default color format should be YUV 4:2:0 in this // specifies that the default color format should be YUV 4:2:0 in this
// case (normative). // case (normative).
cm->color_space = VPX_CS_BT_601; cm->color_space = VPX_CS_BT_601;
cm->color_range = 0; cm->color_range = VPX_CR_STUDIO_RANGE;
cm->subsampling_y = cm->subsampling_x = 1; cm->subsampling_y = cm->subsampling_x = 1;
cm->bit_depth = VPX_BITS_8; cm->bit_depth = VPX_BITS_8;
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH

View File

@ -238,7 +238,7 @@ typedef struct VP9EncoderConfig {
int use_highbitdepth; int use_highbitdepth;
#endif #endif
vpx_color_space_t color_space; vpx_color_space_t color_space;
int color_range; vpx_color_range_t color_range;
int render_width; int render_width;
int render_height; int render_height;
VP9E_TEMPORAL_LAYERING_MODE temporal_layering_mode; VP9E_TEMPORAL_LAYERING_MODE temporal_layering_mode;

View File

@ -45,7 +45,7 @@ struct vp9_extracfg {
vpx_bit_depth_t bit_depth; vpx_bit_depth_t bit_depth;
vp9e_tune_content content; vp9e_tune_content content;
vpx_color_space_t color_space; vpx_color_space_t color_space;
int color_range; vpx_color_range_t color_range;
int render_width; int render_width;
int render_height; int render_height;
}; };
@ -327,7 +327,8 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
ERROR("Codec bit-depth 8 not supported in profile > 1"); ERROR("Codec bit-depth 8 not supported in profile > 1");
} }
RANGE_CHECK(extra_cfg, color_space, VPX_CS_UNKNOWN, VPX_CS_SRGB); RANGE_CHECK(extra_cfg, color_space, VPX_CS_UNKNOWN, VPX_CS_SRGB);
RANGE_CHECK(extra_cfg, color_range, 0, 2); RANGE_CHECK(extra_cfg, color_range,
VPX_CR_STUDIO_RANGE, VPX_CR_FULL_RANGE);
return VPX_CODEC_OK; return VPX_CODEC_OK;
} }

View File

@ -78,11 +78,17 @@ extern "C" {
VPX_CS_SRGB = 7 /**< sRGB */ VPX_CS_SRGB = 7 /**< sRGB */
} vpx_color_space_t; /**< alias for enum vpx_color_space */ } vpx_color_space_t; /**< alias for enum vpx_color_space */
/*!\brief List of supported color range */
typedef enum vpx_color_range {
VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
} vpx_color_range_t; /**< alias for enum vpx_color_range */
/**\brief Image Descriptor */ /**\brief Image Descriptor */
typedef struct vpx_image { typedef struct vpx_image {
vpx_img_fmt_t fmt; /**< Image Format */ vpx_img_fmt_t fmt; /**< Image Format */
vpx_color_space_t cs; /**< Color Space */ vpx_color_space_t cs; /**< Color Space */
int range; /**< Limited (0) vs. Full-range (1) sample data */ vpx_color_range_t range; /**< Color Range */
/* Image storage dimensions */ /* Image storage dimensions */
unsigned int w; /**< Stored image width */ unsigned int w; /**< Stored image width */

View File

@ -56,7 +56,7 @@ typedef struct yv12_buffer_config {
int subsampling_y; int subsampling_y;
unsigned int bit_depth; unsigned int bit_depth;
vpx_color_space_t color_space; vpx_color_space_t color_space;
int color_range; vpx_color_range_t color_range;
int render_width; int render_width;
int render_height; int render_height;