Commit f340fece authored by Debargha Mukherjee's avatar Debargha Mukherjee

No colorspace for mono-video f/ CICP compatibility

Change-Id: I03c6cf0b58f9e1d74c7d30d76e846be9a640dab7
parent f9a50ea3
......@@ -620,6 +620,13 @@ typedef struct aom_codec_enc_cfg {
*/
unsigned int large_scale_tile;
/*!\brief Monochrome mode
*
* If this is nonzero, the encoder will generate a monochrome stream
* with no chroma planes.
*/
unsigned int monochrome;
/*!\brief Number of explicit tile widths specified
*
* This value indicates the number of tile widths specified
......
......@@ -149,8 +149,7 @@ typedef enum aom_color_space {
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_MONOCHROME = 9, /**< Monochrome */
AOM_CS_RESERVED = 10 /**< Values 10..31 are reserved */
AOM_CS_RESERVED = 9, /**< Values 10..31 are reserved */
} aom_color_space_t; /**< alias for enum aom_color_space */
/*!\brief List of supported transfer functions */
......@@ -189,6 +188,7 @@ typedef struct aom_image {
aom_color_space_t cs; /**< Color Space */
aom_transfer_function_t tf; /**< transfer function */
#endif
int monochrome; /**< Whether image is monochrome */
aom_chroma_sample_position_t csp; /**< chroma sample position */
aom_color_range_t range; /**< Color Range */
......
......@@ -106,6 +106,7 @@ typedef struct yv12_buffer_config {
aom_color_space_t color_space;
aom_transfer_function_t transfer_function;
#endif
int monochrome;
aom_chroma_sample_position_t chroma_sample_position;
aom_color_range_t color_range;
int render_width;
......
......@@ -505,6 +505,7 @@ static int main_loop(int argc, const char **argv_) {
int use_y4m = 1;
int opt_yv12 = 0;
int opt_i420 = 0;
int opt_raw = 0;
aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH };
unsigned int output_bit_depth = 0;
#if CONFIG_EXT_TILE
......@@ -561,12 +562,19 @@ static int main_loop(int argc, const char **argv_) {
use_y4m = 0;
flipuv = 1;
opt_yv12 = 1;
opt_i420 = 0;
opt_raw = 0;
} else if (arg_match(&arg, &use_i420, argi)) {
use_y4m = 0;
flipuv = 0;
opt_yv12 = 0;
opt_i420 = 1;
opt_raw = 0;
} else if (arg_match(&arg, &rawvideo, argi)) {
use_y4m = 0;
opt_yv12 = 0;
opt_i420 = 0;
opt_raw = 1;
} else if (arg_match(&arg, &flipuvarg, argi)) {
flipuv = 1;
} else if (arg_match(&arg, &noblitarg, argi)) {
......@@ -909,10 +917,11 @@ static int main_loop(int argc, const char **argv_) {
aom_input_ctx.height = img->d_h;
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO && !CONFIG_CICP
int num_planes = (!use_y4m && img->cs == AOM_CS_MONOCHROME) ? 1 : 3;
#if CONFIG_MONO_VIDEO
int num_planes = (!use_y4m && opt_raw && img->monochrome) ? 1 : 3;
#else
int num_planes = 3;
(void)opt_raw;
#endif
if (single_file) {
......
......@@ -265,6 +265,10 @@ static const arg_def_t large_scale_tile =
ARG_DEF(NULL, "large-scale-tile", 1,
"Large scale tile coding (0: off (default), 1: on)");
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO
static const arg_def_t monochrome =
ARG_DEF(NULL, "monochrome", 0, "Monochrome video (no chroma planes)");
#endif // CONFIG_MONO_VIDEO
static const arg_def_t *global_args[] = { &use_yv12,
&use_i420,
......@@ -287,6 +291,9 @@ static const arg_def_t *global_args[] = { &use_yv12,
#if CONFIG_EXT_TILE
&large_scale_tile,
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO
&monochrome,
#endif // CONFIG_MONO_VIDEO
NULL };
static const arg_def_t dropframe_thresh =
......@@ -575,17 +582,11 @@ static const arg_def_t input_matrix_coefficients = ARG_DEF_ENUM(
#else
static const struct arg_enum_list color_space_enum[] = {
{ "unspecified", AOM_CS_UNKNOWN },
{ "bt601", AOM_CS_BT_601 },
{ "bt709", AOM_CS_BT_709 },
{ "smpte170", AOM_CS_SMPTE_170 },
{ "smpte240", AOM_CS_SMPTE_240 },
{ "bt2020ncl", AOM_CS_BT_2020_NCL },
{ "bt2020cl", AOM_CS_BT_2020_CL },
{ "sRGB", AOM_CS_SRGB },
{ "ictcp", AOM_CS_ICTCP },
{ "monochrome", AOM_CS_MONOCHROME },
{ NULL, 0 }
{ "unspecified", AOM_CS_UNKNOWN }, { "bt601", AOM_CS_BT_601 },
{ "bt709", AOM_CS_BT_709 }, { "smpte170", AOM_CS_SMPTE_170 },
{ "smpte240", AOM_CS_SMPTE_240 }, { "bt2020ncl", AOM_CS_BT_2020_NCL },
{ "bt2020cl", AOM_CS_BT_2020_CL }, { "sRGB", AOM_CS_SRGB },
{ "ictcp", AOM_CS_ICTCP }, { NULL, 0 }
};
static const arg_def_t input_color_space =
......@@ -1219,6 +1220,10 @@ static int parse_stream_params(struct AvxEncoderConfig *global,
} else if (arg_match(&arg, &large_scale_tile, argi)) {
config->cfg.large_scale_tile = arg_parse_uint(&arg);
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO
} else if (arg_match(&arg, &monochrome, argi)) {
config->cfg.monochrome = 1;
#endif // CONFIG_MONO_VIDEO
} else if (arg_match(&arg, &dropframe_thresh, argi)) {
config->cfg.rc_dropframe_thresh = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_mode, argi)) {
......
......@@ -334,6 +334,9 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO
RANGE_CHECK_HI(cfg, monochrome, 1);
#endif // CONFIG_MONO_VIDEO
#if CONFIG_EXT_TILE
if (cfg->large_scale_tile && extra_cfg->aq_mode)
......@@ -409,22 +412,14 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
AOM_CICP_MC_ICTCP);
#else
#if CONFIG_COLORSPACE_HEADERS
#if CONFIG_MONO_VIDEO
RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_MONOCHROME);
#else
RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_ICTCP);
#endif // CONFIG_MONO_VIDEO
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
#if CONFIG_MONO_VIDEO
RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_MONOCHROME);
#else
RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_SRGB);
#endif
#endif
#endif
#endif // CONFIG_COLORSPACE_HEADERS
#endif // CONFIG_CICP
RANGE_CHECK(extra_cfg, color_range, 0, 1);
#if CONFIG_DIST_8X8
......@@ -621,8 +616,7 @@ static aom_codec_err_t set_encoder_config(
oxcf->matrix_coefficients = extra_cfg->matrix_coefficients;
#else
oxcf->color_space = extra_cfg->color_space;
#endif
#endif // CONFIG_CICP
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
oxcf->transfer_function = extra_cfg->transfer_function;
......@@ -681,6 +675,9 @@ static aom_codec_err_t set_encoder_config(
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO
oxcf->monochrome = cfg->monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_MAX_TILE
oxcf->tile_width_count = AOMMIN(cfg->tile_width_count, MAX_TILE_COLS);
......@@ -1800,6 +1797,7 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
0, // kf_min_dist
9999, // kf_max_dist
0, // large_scale_tile
0, // monochrome
0, // tile_width_count
0, // tile_height_count
{ 0 }, // tile_widths
......
......@@ -172,17 +172,18 @@ static int parse_bitdepth_colorspace_sampling(BITSTREAM_PROFILE profile,
aom_color_primaries_t color_primaries;
aom_transfer_characteristics_t transfer_characteristics;
aom_matrix_coefficients_t matrix_coefficients;
#else
aom_color_space_t color_space = AOM_CS_UNKNOWN;
#endif // CONFIG_CICP
int subsampling_x = 0;
int subsampling_y = 0;
aom_color_space_t color_space;
(void)subsampling_x;
(void)subsampling_y;
aom_bit_depth_t bit_depth = parse_bitdepth(profile, rb);
color_space = AOM_CS_UNKNOWN;
#if CONFIG_MONO_VIDEO
// Monochrome bit
const int is_monochrome = profile != PROFILE_1 ? aom_rb_read_bit(rb) : 0;
color_space = is_monochrome ? AOM_CS_MONOCHROME : AOM_CS_UNKNOWN;
#else
const int is_monochrome = 0;
#endif // CONFIG_MONO_VIDEO
......
......@@ -44,6 +44,7 @@ static void yuvconfig2image(aom_image_t *img, const YV12_BUFFER_CONFIG *yv12,
#else
img->cs = yv12->color_space;
#endif
img->monochrome = yv12->monochrome;
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
img->tf = yv12->transfer_function;
......@@ -118,6 +119,7 @@ static aom_codec_err_t image2yuvconfig(const aom_image_t *img,
#else
yv12->color_space = img->cs;
#endif
yv12->monochrome = img->monochrome;
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
yv12->transfer_function = img->tf;
......
......@@ -219,6 +219,9 @@ typedef struct SequenceHeader {
int frame_id_numbers_present_flag;
int frame_id_length;
int delta_frame_id_length;
#if CONFIG_MONO_VIDEO
int monochrome;
#endif // CONFIG_MONO_VIDEO
} SequenceHeader;
#endif // CONFIG_REFERENCE_BUFFER
......@@ -1138,12 +1141,12 @@ static INLINE int max_intra_block_height(const MACROBLOCKD *xd,
#endif // CONFIG_CFL
static INLINE int av1_num_planes(const AV1_COMMON *cm) {
#if CONFIG_MONO_VIDEO && !CONFIG_CICP
return cm->color_space == AOM_CS_MONOCHROME ? 1 : MAX_MB_PLANE;
#if CONFIG_MONO_VIDEO
return cm->seq_params.monochrome ? 1 : MAX_MB_PLANE;
#else
(void)cm;
return MAX_MB_PLANE;
#endif
#endif // CONFIG_MONO_VIDEO
}
static INLINE void av1_zero_above_context(AV1_COMMON *const cm,
......
......@@ -1250,6 +1250,9 @@ static void setup_frame_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#else
pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
#endif
#if CONFIG_MONO_VIDEO
pool->frame_bufs[cm->new_fb_idx].buf.monochrome = cm->seq_params.monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
pool->frame_bufs[cm->new_fb_idx].buf.transfer_function =
......@@ -1367,6 +1370,9 @@ static void setup_frame_size_with_refs(AV1_COMMON *cm,
#else
pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
#endif
#if CONFIG_MONO_VIDEO
pool->frame_bufs[cm->new_fb_idx].buf.monochrome = cm->seq_params.monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
pool->frame_bufs[cm->new_fb_idx].buf.transfer_function =
......@@ -2158,7 +2164,7 @@ void av1_read_bitdepth_colorspace_sampling(AV1_COMMON *cm,
#if CONFIG_MONO_VIDEO
// monochrome bit (not needed for PROFILE_1)
const int is_monochrome = cm->profile != PROFILE_1 ? aom_rb_read_bit(rb) : 0;
cm->color_space = is_monochrome ? AOM_CS_MONOCHROME : AOM_CS_UNKNOWN;
cm->seq_params.monochrome = is_monochrome;
#elif !CONFIG_CICP
const int is_monochrome = 0;
#endif // CONFIG_MONO_VIDEO
......@@ -2174,6 +2180,7 @@ void av1_read_bitdepth_colorspace_sampling(AV1_COMMON *cm,
cm->matrix_coefficients = AOM_CICP_MC_UNSPECIFIED;
}
#else
cm->color_space = AOM_CS_UNKNOWN;
#if CONFIG_COLORSPACE_HEADERS
if (!is_monochrome) cm->color_space = aom_rb_read_literal(rb, 5);
cm->transfer_function = aom_rb_read_literal(rb, 5);
......@@ -2908,6 +2915,9 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#else
get_frame_new_buffer(cm)->color_space = cm->color_space;
#endif
#if CONFIG_MONO_VIDEO
get_frame_new_buffer(cm)->monochrome = cm->seq_params.monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
get_frame_new_buffer(cm)->transfer_function = cm->transfer_function;
......
......@@ -1011,10 +1011,7 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
const int uv_dc_pred =
#if CONFIG_MONO_VIDEO
av1_num_planes(cm) > 1 &&
#endif
mbmi->uv_mode == UV_DC_PRED &&
av1_num_planes(cm) > 1 && mbmi->uv_mode == UV_DC_PRED &&
is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y);
if (uv_dc_pred) {
......@@ -3284,7 +3281,7 @@ static void write_bitdepth_colorspace_sampling(
AV1_COMMON *const cm, struct aom_write_bit_buffer *wb) {
write_bitdepth(cm, wb);
#if CONFIG_MONO_VIDEO
const int is_monochrome = cm->color_space == AOM_CS_MONOCHROME;
const int is_monochrome = cm->seq_params.monochrome;
// monochrome bit
if (cm->profile != PROFILE_1)
aom_wb_write_bit(wb, is_monochrome);
......
......@@ -1054,6 +1054,9 @@ static void init_config(struct AV1_COMP *cpi, AV1EncoderConfig *oxcf) {
#else
cm->color_space = oxcf->color_space;
#endif // CONFIG_CICP
#if CONFIG_MONO_VIDEO
cm->seq_params.monochrome = oxcf->monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
cm->transfer_function = oxcf->transfer_function;
......@@ -3082,6 +3085,9 @@ void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
#else
cm->color_space = oxcf->color_space;
#endif
#if CONFIG_MONO_VIDEO
cm->seq_params.monochrome = oxcf->monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
cm->transfer_function = oxcf->transfer_function;
......@@ -6076,6 +6082,10 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
#endif // CONFIG_REFERENCE_BUFFER
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO
cm->seq_params.monochrome = oxcf->monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_XIPHRC
if (drop_this_frame) {
av1_rc_postencode_update_drop_frame(cpi);
......@@ -6178,6 +6188,9 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
#else
cm->frame_to_show->color_space = cm->color_space;
#endif
#if CONFIG_MONO_VIDEO
cm->frame_to_show->monochrome = cm->seq_params.monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_COLORSPACE_HEADERS
#if !CONFIG_CICP
cm->frame_to_show->transfer_function = cm->transfer_function;
......
......@@ -305,6 +305,9 @@ typedef struct AV1EncoderConfig {
unsigned int large_scale_tile;
unsigned int single_tile_decoding;
#endif // CONFIG_EXT_TILE
#if CONFIG_MONO_VIDEO
int monochrome;
#endif // CONFIG_MONO_VIDEO
unsigned int motion_vector_unit_test;
} AV1EncoderConfig;
......
......@@ -40,6 +40,7 @@ static void find_mismatch_plane(const aom_image_t *const img1,
assert(img1->x_chroma_shift == img2->x_chroma_shift &&
img1->y_chroma_shift == img2->y_chroma_shift);
loc[0] = loc[1] = loc[2] = loc[3] = -1;
if (img1->monochrome && img2->monochrome && plane) return;
int match = 1;
uint32_t i, j;
for (i = 0; match && i < c_h; i += bsizey) {
......@@ -105,13 +106,9 @@ int aom_compare_img(const aom_image_t *const img1,
#else
assert(img1->cs == img2->cs);
#endif
assert(img1->monochrome == img2->monochrome);
#if CONFIG_CICP
int num_planes = 3; // We need to decide on monochrome video based
// on something else than the color space
#else
int num_planes = img1->cs == AOM_CS_MONOCHROME ? 1 : 3;
#endif
int num_planes = img1->monochrome ? 1 : 3;
uint32_t l_w = img1->d_w;
uint32_t c_w = (img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift;
......
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