Commit 76fb1265 authored by anorkin's avatar anorkin Committed by Andrey Norkin

Experiment: adding the source video information signaling (Netflix)

Change-Id: If93f9e41c25a5885b5927e66a298c129bb844e18
parent aba246dc
......@@ -35,6 +35,8 @@ extern "C" {
#define AOM_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
#define AOM_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
#include "./aom_config.h"
/*!\brief List of supported image formats */
typedef enum aom_img_fmt {
AOM_IMG_FMT_NONE,
......@@ -74,10 +76,28 @@ typedef enum aom_color_space {
AOM_CS_BT_709 = 2, /**< BT.709 */
AOM_CS_SMPTE_170 = 3, /**< SMPTE.170 */
AOM_CS_SMPTE_240 = 4, /**< SMPTE.240 */
AOM_CS_BT_2020 = 5, /**< BT.2020 */
AOM_CS_RESERVED = 6, /**< Reserved */
AOM_CS_SRGB = 7 /**< sRGB */
} aom_color_space_t; /**< alias for enum aom_color_space */
#if CONFIG_COLORSPACE_HEADERS
AOM_CS_BT_2020_NCL = 5, /**< BT.2020 non-constant luminance (BT.2100) */
AOM_CS_BT_2020_CL = 6, /**< BT.2020 constant luminance */
AOM_CS_SRGB = 7, /**< sRGB */
AOM_CS_ICTCP = 8, /**< ICtCp, ITU-R BT.2100 */
AOM_CS_RESERVED = 9 /**< Values 9..31 are reserved */
#else
AOM_CS_BT_2020 = 5, /**< BT.2020 */
AOM_CS_RESERVED = 6, /**< Reserved */
AOM_CS_SRGB = 7 /**< sRGB */
#endif
} aom_color_space_t; /**< alias for enum aom_color_space */
#if CONFIG_COLORSPACE_HEADERS
typedef enum aom_transfer_function {
AOM_TF_UNKNOWN = 0, /**< Unknown */
AOM_TF_BT_709 = 1, /**< BT.709 */
AOM_TF_PQ = 2, /**< PQ TF BT.2100 / ST.2084 */
AOM_TF_HLG = 3, /**< Hybrid Log-Gamma */
AOM_TF_RESERVED = 4 /**< Values 4..31 are reserved */
} aom_transfer_function_t; /**< alias for enum aom_transfer_function */
#endif
/*!\brief List of supported color range */
typedef enum aom_color_range {
......@@ -85,10 +105,24 @@ typedef enum aom_color_range {
AOM_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
} aom_color_range_t; /**< alias for enum aom_color_range */
#if CONFIG_COLORSPACE_HEADERS
typedef enum aom_chroma_sample_position {
AOM_CSP_UNKNOWN = 0, /**< Unknown */
AOM_CSP_VERTICAL = 1, /**< Horizontally co-located with luma(0, 0)*/
/**< sample, between two vertical samples */
AOM_CSP_COLOCATED = 2, /**< Co-located with luma(0, 0) sample */
AOM_CSP_RESERVED = 3 /**< Reserved value */
} aom_chroma_sample_position_t; /**< alias for enum aom_transfer_function */
#endif
/**\brief Image Descriptor */
typedef struct aom_image {
aom_img_fmt_t fmt; /**< Image Format */
aom_color_space_t cs; /**< Color Space */
aom_img_fmt_t fmt; /**< Image Format */
aom_color_space_t cs; /**< Color Space */
#if CONFIG_COLORSPACE_HEADERS
aom_transfer_function_t tf; /**< transfer function */
aom_chroma_sample_position_t csp; /**< chroma sample position */
#endif
aom_color_range_t range; /**< Color Range */
/* Image storage dimensions */
......
......@@ -327,18 +327,41 @@ enum aome_enc_control_id {
AV1E_SET_TUNE_CONTENT,
/*!\brief Codec control function to set color space info.
* \note Valid ranges: 0..7, default is "UNKNOWN".
* \note Valid ranges: 0..9, default is "UNKNOWN".
* 0 = UNKNOWN,
* 1 = BT_601
* 2 = BT_709
* 3 = SMPTE_170
* 4 = SMPTE_240
* 5 = BT_2020
* 6 = RESERVED
* 5 = BT_2020_NCL
* 6 = BT_2020_CL
* 7 = SRGB
* 8 = ICtCp
* 9 = RESERVED
*/
AV1E_SET_COLOR_SPACE,
#if CONFIG_COLORSPACE_HEADERS
/*!\brief Codec control function to set transfer function info.
* \note Valid ranges: 0..4, default is "UNKNOWN".
* 0 = UNKNOWN,
* 1 = BT_709
* 2 = PQ
* 3 = HLG
* 4 = RESERVED
*/
AV1E_SET_TRANSFER_FUNCTION,
/*!\brief Codec control function to set chroma 4:2:0 sample position info.
* \note Valid ranges: 0..3, default is "UNKNOWN".
* 0 = UNKNOWN,
* 1 = VERTICAL
* 2 = COLOCATED
* 3 = RESERVED
*/
AV1E_SET_CHROMA_SAMPLE_POSITION,
#endif
/*!\brief Codec control function to set minimum interval between GF/ARF frames
*
* By default the value is set as 4.
......@@ -704,6 +727,14 @@ AOM_CTRL_USE_TYPE(AV1E_SET_TUNE_CONTENT, int) /* aom_tune_content */
AOM_CTRL_USE_TYPE(AV1E_SET_COLOR_SPACE, int)
#define AOM_CTRL_AV1E_SET_COLOR_SPACE
#if CONFIG_COLORSPACE_HEADERS
AOM_CTRL_USE_TYPE(AV1E_SET_TRANSFER_FUNCTION, int)
#define AOM_CTRL_AV1E_SET_TRANSFER_FUNCTION
AOM_CTRL_USE_TYPE(AV1E_SET_CHROMA_SAMPLE_POSITION, int)
#define AOM_CTRL_AV1E_SET_CHROMA_SAMPLE_POSITION
#endif
AOM_CTRL_USE_TYPE(AV1E_SET_MIN_GF_INTERVAL, unsigned int)
#define AOM_CTRL_AV1E_SET_MIN_GF_INTERVAL
......
......@@ -69,6 +69,10 @@ typedef struct yv12_buffer_config {
int subsampling_y;
unsigned int bit_depth;
aom_color_space_t color_space;
#if CONFIG_COLORSPACE_HEADERS
aom_transfer_function_t transfer_function;
aom_chroma_sample_position_t chroma_sample_position;
#endif
aom_color_range_t color_range;
int render_width;
int render_height;
......
......@@ -436,9 +436,16 @@ static const struct arg_enum_list color_space_enum[] = {
{ "bt709", AOM_CS_BT_709 },
{ "smpte170", AOM_CS_SMPTE_170 },
{ "smpte240", AOM_CS_SMPTE_240 },
#if CONFIG_COLORSPACE_HEADERS
{ "bt2020ncl", AOM_CS_BT_2020_NCL },
{ "bt2020cl", AOM_CS_BT_2020_CL },
{ "sRGB", AOM_CS_SRGB },
{ "ICtCp", AOM_CS_ICTCP },
#else
{ "bt2020", AOM_CS_BT_2020 },
{ "reserved", AOM_CS_RESERVED },
{ "sRGB", AOM_CS_SRGB },
#endif
{ NULL, 0 }
};
......@@ -446,6 +453,32 @@ static const arg_def_t input_color_space =
ARG_DEF_ENUM(NULL, "color-space", 1, "The color space of input content:",
color_space_enum);
#if CONFIG_COLORSPACE_HEADERS
static const struct arg_enum_list transfer_function_enum[] = {
{ "unknown", AOM_TF_UNKNOWN },
{ "bt709", AOM_TF_BT_709 },
{ "pq", AOM_TF_PQ },
{ "hlg", AOM_TF_HLG },
{ NULL, 0 }
};
static const arg_def_t input_transfer_function = ARG_DEF_ENUM(
NULL, "transfer-function", 1, "The transfer function of input content:",
transfer_function_enum);
static const struct arg_enum_list chroma_sample_position_enum[] = {
{ "unknown", AOM_CSP_UNKNOWN },
{ "vertical", AOM_CSP_VERTICAL },
{ "colocated", AOM_CSP_COLOCATED },
{ NULL, 0 }
};
static const arg_def_t input_chroma_sample_position =
ARG_DEF_ENUM(NULL, "chroma-sample-position", 1,
"The chroma sample position when chroma 4:2:0 is signaled:",
chroma_sample_position_enum);
#endif
static const struct arg_enum_list tune_content_enum[] = {
{ "default", AOM_CONTENT_DEFAULT },
{ "screen", AOM_CONTENT_SCREEN },
......@@ -505,6 +538,10 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&noise_sens,
&tune_content,
&input_color_space,
#if CONFIG_COLORSPACE_HEADERS
&input_transfer_function,
&input_chroma_sample_position,
#endif
&min_gf_interval,
&max_gf_interval,
#if CONFIG_EXT_PARTITION
......@@ -559,6 +596,10 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
AV1E_SET_NOISE_SENSITIVITY,
AV1E_SET_TUNE_CONTENT,
AV1E_SET_COLOR_SPACE,
#if CONFIG_COLORSPACE_HEADERS
AV1E_SET_TRANSFER_FUNCTION,
AV1E_SET_CHROMA_SAMPLE_POSITION,
#endif
AV1E_SET_MIN_GF_INTERVAL,
AV1E_SET_MAX_GF_INTERVAL,
#if CONFIG_EXT_PARTITION
......
......@@ -71,6 +71,10 @@ struct av1_extracfg {
aom_bit_depth_t bit_depth;
aom_tune_content content;
aom_color_space_t color_space;
#if CONFIG_COLORSPACE_HEADERS
aom_transfer_function_t transfer_function;
aom_chroma_sample_position_t chroma_sample_position;
#endif
int color_range;
int render_width;
int render_height;
......@@ -102,7 +106,7 @@ static struct av1_extracfg default_extra_cfg = {
0, // tile_rows
#endif // CONFIG_EXT_TILE
#if CONFIG_DEPENDENT_HORZTILES
0, // Depdendent Horizontal tiles
0, // Dependent Horizontal tiles
#endif
#if CONFIG_LOOPFILTERING_ACROSS_TILES
1, // loop_filter_across_tiles_enabled
......@@ -134,10 +138,14 @@ static struct av1_extracfg default_extra_cfg = {
#if CONFIG_EXT_DELTA_Q
NO_DELTA_Q, // deltaq_mode
#endif
CONFIG_XIPHRC, // frame_periodic_delta_q
AOM_BITS_8, // Bit depth
AOM_CONTENT_DEFAULT, // content
AOM_CS_UNKNOWN, // color space
CONFIG_XIPHRC, // frame_periodic_delta_q
AOM_BITS_8, // Bit depth
AOM_CONTENT_DEFAULT, // content
AOM_CS_UNKNOWN, // color space
#if CONFIG_COLORSPACE_HEADERS
AOM_TF_UNKNOWN, // transfer function
AOM_CSP_UNKNOWN, // chroma sample position
#endif
0, // color range
0, // render width
0, // render height
......@@ -354,7 +362,14 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
cfg->g_bit_depth == AOM_BITS_8) {
ERROR("Codec bit-depth 8 not supported in profile > 1");
}
#if CONFIG_COLORSPACE_HEADERS
RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_ICTCP);
RANGE_CHECK(extra_cfg, transfer_function, AOM_TF_UNKNOWN, AOM_TF_HLG);
RANGE_CHECK(extra_cfg, chroma_sample_position, AOM_CSP_UNKNOWN,
AOM_CSP_COLOCATED);
#else
RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_SRGB);
#endif
RANGE_CHECK(extra_cfg, color_range, 0, 1);
#if CONFIG_ANS && ANS_MAX_SYMBOLS
RANGE_CHECK(extra_cfg, ans_window_size_log2, 8, 23);
......@@ -523,6 +538,10 @@ static aom_codec_err_t set_encoder_config(
#endif
oxcf->color_space = extra_cfg->color_space;
#if CONFIG_COLORSPACE_HEADERS
oxcf->transfer_function = extra_cfg->transfer_function;
oxcf->chroma_sample_position = extra_cfg->chroma_sample_position;
#endif
oxcf->color_range = extra_cfg->color_range;
oxcf->render_width = extra_cfg->render_width;
oxcf->render_height = extra_cfg->render_height;
......@@ -1419,6 +1438,23 @@ static aom_codec_err_t ctrl_set_color_space(aom_codec_alg_priv_t *ctx,
return update_extra_cfg(ctx, &extra_cfg);
}
#if CONFIG_COLORSPACE_HEADERS
static aom_codec_err_t ctrl_set_transfer_function(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.transfer_function = CAST(AV1E_SET_TRANSFER_FUNCTION, args);
return update_extra_cfg(ctx, &extra_cfg);
}
static aom_codec_err_t ctrl_set_chroma_sample_position(
aom_codec_alg_priv_t *ctx, va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.chroma_sample_position =
CAST(AV1E_SET_CHROMA_SAMPLE_POSITION, args);
return update_extra_cfg(ctx, &extra_cfg);
}
#endif
static aom_codec_err_t ctrl_set_color_range(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
......@@ -1504,6 +1540,10 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
{ AV1E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost },
{ AV1E_SET_TUNE_CONTENT, ctrl_set_tune_content },
{ AV1E_SET_COLOR_SPACE, ctrl_set_color_space },
#if CONFIG_COLORSPACE_HEADERS
{ AV1E_SET_TRANSFER_FUNCTION, ctrl_set_transfer_function },
{ AV1E_SET_CHROMA_SAMPLE_POSITION, ctrl_set_chroma_sample_position },
#endif
{ AV1E_SET_COLOR_RANGE, ctrl_set_color_range },
{ AV1E_SET_NOISE_SENSITIVITY, ctrl_set_noise_sensitivity },
{ AV1E_SET_MIN_GF_INTERVAL, ctrl_set_min_gf_interval },
......
......@@ -154,14 +154,40 @@ static aom_codec_err_t decoder_destroy(aom_codec_alg_priv_t *ctx) {
static int parse_bitdepth_colorspace_sampling(BITSTREAM_PROFILE profile,
struct aom_read_bit_buffer *rb) {
aom_color_space_t color_space;
#if CONFIG_COLORSPACE_HEADERS
int subsampling_x = 0;
int subsampling_y = 0;
#endif
if (profile >= PROFILE_2) rb->bit_offset += 1; // Bit-depth 10 or 12.
#if CONFIG_COLORSPACE_HEADERS
color_space = (aom_color_space_t)aom_rb_read_literal(rb, 5);
rb->bit_offset += 5; // Transfer function
#else
color_space = (aom_color_space_t)aom_rb_read_literal(rb, 3);
#endif
if (color_space != AOM_CS_SRGB) {
rb->bit_offset += 1; // [16,235] (including xvycc) vs [0,255] range.
if (profile == PROFILE_1 || profile == PROFILE_3) {
#if CONFIG_COLORSPACE_HEADERS
subsampling_x = aom_rb_read_bit(rb);
subsampling_y = aom_rb_read_bit(rb);
#else
rb->bit_offset += 2; // subsampling x/y.
#endif
rb->bit_offset += 1; // unused.
#if CONFIG_COLORSPACE_HEADERS
} else {
subsampling_x = 1;
subsampling_y = 1;
}
if (subsampling_x == 1 && subsampling_y == 1) {
rb->bit_offset += 2;
}
#else
}
#endif
} else {
if (profile == PROFILE_1 || profile == PROFILE_3) {
rb->bit_offset += 1; // unused
......
......@@ -38,6 +38,10 @@ static void yuvconfig2image(aom_image_t *img, const YV12_BUFFER_CONFIG *yv12,
}
}
img->cs = yv12->color_space;
#if CONFIG_COLORSPACE_HEADERS
img->tf = yv12->transfer_function;
img->csp = yv12->chroma_sample_position;
#endif
img->range = yv12->color_range;
img->bit_depth = 8;
img->w = yv12->y_stride;
......@@ -102,6 +106,10 @@ static aom_codec_err_t image2yuvconfig(const aom_image_t *img,
yv12->y_stride = img->stride[AOM_PLANE_Y];
yv12->uv_stride = img->stride[AOM_PLANE_U];
yv12->color_space = img->cs;
#if CONFIG_COLORSPACE_HEADERS
yv12->transfer_function = img->tf;
yv12->chroma_sample_position = img->csp;
#endif
yv12->color_range = img->range;
#if CONFIG_HIGHBITDEPTH
......
......@@ -153,6 +153,10 @@ typedef struct BufferPool {
typedef struct AV1Common {
struct aom_internal_error_info error;
aom_color_space_t color_space;
#if CONFIG_COLORSPACE_HEADERS
aom_transfer_function_t transfer_function;
aom_chroma_sample_position_t chroma_sample_position;
#endif
int color_range;
int width;
int height;
......
......@@ -3157,6 +3157,12 @@ static void setup_frame_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y;
pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
#if CONFIG_COLORSPACE_HEADERS
pool->frame_bufs[cm->new_fb_idx].buf.transfer_function =
cm->transfer_function;
pool->frame_bufs[cm->new_fb_idx].buf.chroma_sample_position =
cm->chroma_sample_position;
#endif
pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
......@@ -3246,6 +3252,12 @@ static void setup_frame_size_with_refs(AV1_COMMON *cm,
pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y;
pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
#if CONFIG_COLORSPACE_HEADERS
pool->frame_bufs[cm->new_fb_idx].buf.transfer_function =
cm->transfer_function;
pool->frame_bufs[cm->new_fb_idx].buf.chroma_sample_position =
cm->chroma_sample_position;
#endif
pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
......@@ -4213,8 +4225,12 @@ static void read_bitdepth_colorspace_sampling(AV1_COMMON *cm,
#if CONFIG_HIGHBITDEPTH
cm->use_highbitdepth = cm->bit_depth > AOM_BITS_8 || !CONFIG_LOWBITDEPTH;
#endif
#if CONFIG_COLORSPACE_HEADERS
cm->color_space = aom_rb_read_literal(rb, 5);
cm->transfer_function = aom_rb_read_literal(rb, 5);
#else
cm->color_space = aom_rb_read_literal(rb, 3);
#endif
if (cm->color_space != AOM_CS_SRGB) {
// [16,235] (including xvycc) vs [0,255] range
cm->color_range = aom_rb_read_bit(rb);
......@@ -4230,6 +4246,11 @@ static void read_bitdepth_colorspace_sampling(AV1_COMMON *cm,
} else {
cm->subsampling_y = cm->subsampling_x = 1;
}
#if CONFIG_COLORSPACE_HEADERS
if (cm->subsampling_x == 1 && cm->subsampling_y == 1) {
cm->chroma_sample_position = aom_rb_read_literal(rb, 2);
}
#endif
} else {
if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) {
// Note if colorspace is SRGB then 4:4:4 chroma sampling is assumed.
......@@ -4598,6 +4619,10 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
get_frame_new_buffer(cm)->bit_depth = cm->bit_depth;
get_frame_new_buffer(cm)->color_space = cm->color_space;
#if CONFIG_COLORSPACE_HEADERS
get_frame_new_buffer(cm)->transfer_function = cm->transfer_function;
get_frame_new_buffer(cm)->chroma_sample_position = cm->chroma_sample_position;
#endif
get_frame_new_buffer(cm)->color_range = cm->color_range;
get_frame_new_buffer(cm)->render_width = cm->render_width;
get_frame_new_buffer(cm)->render_height = cm->render_height;
......
......@@ -4382,7 +4382,12 @@ static void write_bitdepth_colorspace_sampling(
assert(cm->bit_depth > AOM_BITS_8);
aom_wb_write_bit(wb, cm->bit_depth == AOM_BITS_10 ? 0 : 1);
}
#if CONFIG_COLORSPACE_HEADERS
aom_wb_write_literal(wb, cm->color_space, 5);
aom_wb_write_literal(wb, cm->transfer_function, 5);
#else
aom_wb_write_literal(wb, cm->color_space, 3);
#endif
if (cm->color_space != AOM_CS_SRGB) {
// 0: [16, 235] (i.e. xvYCC), 1: [0, 255]
aom_wb_write_bit(wb, cm->color_range);
......@@ -4394,6 +4399,11 @@ static void write_bitdepth_colorspace_sampling(
} else {
assert(cm->subsampling_x == 1 && cm->subsampling_y == 1);
}
#if CONFIG_COLORSPACE_HEADERS
if (cm->subsampling_x == 1 && cm->subsampling_y == 1) {
aom_wb_write_literal(wb, cm->chroma_sample_position, 2);
}
#endif
} else {
assert(cm->profile == PROFILE_1 || cm->profile == PROFILE_3);
aom_wb_write_bit(wb, 0); // unused
......
......@@ -970,6 +970,10 @@ static void init_config(struct AV1_COMP *cpi, AV1EncoderConfig *oxcf) {
cm->use_highbitdepth = oxcf->use_highbitdepth;
#endif
cm->color_space = oxcf->color_space;
#if CONFIG_COLORSPACE_HEADERS
cm->transfer_function = oxcf->transfer_function;
cm->chroma_sample_position = oxcf->chroma_sample_position;
#endif
cm->color_range = oxcf->color_range;
cm->width = oxcf->width;
......@@ -1942,6 +1946,10 @@ void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
if (cm->profile != oxcf->profile) cm->profile = oxcf->profile;
cm->bit_depth = oxcf->bit_depth;
cm->color_space = oxcf->color_space;
#if CONFIG_COLORSPACE_HEADERS
cm->transfer_function = oxcf->transfer_function;
cm->chroma_sample_position = oxcf->chroma_sample_position;
#endif
cm->color_range = oxcf->color_range;
if (cm->profile <= PROFILE_1)
......@@ -4824,6 +4832,10 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
cm->frame_to_show = get_frame_new_buffer(cm);
cm->frame_to_show->color_space = cm->color_space;
#if CONFIG_COLORSPACE_HEADERS
cm->frame_to_show->transfer_function = cm->transfer_function;
cm->frame_to_show->chroma_sample_position = cm->chroma_sample_position;
#endif
cm->frame_to_show->color_range = cm->color_range;
cm->frame_to_show->render_width = cm->render_width;
cm->frame_to_show->render_height = cm->render_height;
......
......@@ -266,6 +266,10 @@ typedef struct AV1EncoderConfig {
int use_highbitdepth;
#endif
aom_color_space_t color_space;
#if CONFIG_COLORSPACE_HEADERS
aom_transfer_function_t transfer_function;
aom_chroma_sample_position_t chroma_sample_position;
#endif
int color_range;
int render_width;
int render_height;
......
......@@ -369,6 +369,7 @@ CONFIG_LIST="
highbitdepth
experimental
size_limit
colorspace_headers
${EXPERIMENT_LIST}
analyzer
"
......@@ -426,6 +427,8 @@ CMDLINE_SELECT="
aom_highbitdepth
highbitdepth
experimental
colorspace_headers
tile_groups
"
process_cmdline() {
......
......@@ -41,6 +41,10 @@ struct EncodeParameters {
int32_t frame_parallel;
aom_color_range_t color_range;
aom_color_space_t cs;
#if CONFIG_COLORSPACE_HEADERS
aom_transfer_function_t tf;
aom_chroma_sample_position_t csp;
#endif
int render_size[2];
// TODO(JBB): quantizers / bitrate
};
......@@ -48,7 +52,11 @@ struct EncodeParameters {
const EncodeParameters kAV1EncodeParameterSet[] = {
{ 0, 0, 0, 1, 0, AOM_CR_STUDIO_RANGE, AOM_CS_BT_601, { 0, 0 } },
{ 0, 0, 0, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_709, { 0, 0 } },
#if CONFIG_COLORSPACE_HEADERS
{ 0, 0, 1, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_2020_NCL, { 0, 0 } },
#else
{ 0, 0, 1, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_2020, { 0, 0 } },
#endif
{ 0, 2, 0, 0, 1, AOM_CR_STUDIO_RANGE, AOM_CS_UNKNOWN, { 640, 480 } },
// TODO(JBB): Test profiles (requires more work).
};
......@@ -78,6 +86,10 @@ class AvxEncoderParmsGetToDecoder
::libaom_test::Encoder *encoder) {
if (video->frame() == 1) {
encoder->Control(AV1E_SET_COLOR_SPACE, encode_parms.cs);
#if CONFIG_COLORSPACE_HEADERS
encoder->Control(AV1E_SET_TRANSFER_FUNCTION, encode_parms.tf);
encoder->Control(AV1E_SET_CHROMA_SAMPLE_POSITION, encode_parms.csp);
#endif
encoder->Control(AV1E_SET_COLOR_RANGE, encode_parms.color_range);
encoder->Control(AV1E_SET_LOSSLESS, encode_parms.lossless);
encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING,
......@@ -115,6 +127,10 @@ class AvxEncoderParmsGetToDecoder
}
EXPECT_EQ(encode_parms.color_range, common->color_range);
EXPECT_EQ(encode_parms.cs, common->color_space);
#if CONFIG_COLORSPACE_HEADERS
EXPECT_EQ(encode_parms.tf, common->transfer_function);
EXPECT_EQ(encode_parms.csp, common->chroma_sample_position);
#endif
if (encode_parms.render_size[0] > 0 && encode_parms.render_size[1] > 0) {
EXPECT_EQ(encode_parms.render_size[0], common->render_width);
EXPECT_EQ(encode_parms.render_size[1], common->render_height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment