Plumb in a "monochrome" flag
This bit appears in the sequence header. At the moment, it does
nothing, but it will mean that we don't encode (or read) chroma
planes.
This patch adds the flag to the sequence header, and also adds an
encoder option (--monochrome) which enables it. At the moment, this
doesn't do anything except cause the bit to be set correctly in the
header.
Change-Id: If5598412c1c75101553d7f8f9098f9ed1163514e
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h
index 208ba01..7a7f4e4 100644
--- a/aom/aom_encoder.h
+++ b/aom/aom_encoder.h
@@ -620,6 +620,13 @@
*/
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
diff --git a/aomenc.c b/aomenc.c
index 0ed4714..0128490 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -260,6 +260,10 @@
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 // MONOCHROME
static const arg_def_t *global_args[] = { &use_yv12,
&use_i420,
@@ -284,6 +288,9 @@
#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 =
@@ -1065,6 +1072,10 @@
} 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)) {
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 91e43db..925077f 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -319,6 +319,9 @@
#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)
@@ -643,6 +646,9 @@
#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);
@@ -1711,6 +1717,7 @@
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
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index ec896c2..3a02a8b 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -281,11 +281,8 @@
}
error_resilient = aom_rb_read_bit(&rb);
#if CONFIG_REFERENCE_BUFFER
-#if CONFIG_FRAME_SIZE
- SequenceHeader seq_params = { 0, 0, 0, 0, 0, 0, 0 };
-#else
- SequenceHeader seq_params = { 0, 0, 0 };
-#endif
+ SequenceHeader seq_params;
+ memset(&seq_params, 0, sizeof(seq_params));
if (si->is_kf) {
/* TODO: Move outside frame loop or inside key-frame branch */
read_sequence_header(&seq_params, &rb);
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 1666ffc..3f4c4d3 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -216,6 +216,9 @@
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
@@ -480,6 +483,10 @@
unsigned int single_tile_decoding;
#endif // CONFIG_EXT_TILE
+#if CONFIG_MONO_VIDEO
+ int monochrome;
+#endif // CONFIG_MONO_VIDEO
+
#if CONFIG_DEPENDENT_HORZTILES
int dependent_horz_tiles;
int tile_group_start_row[MAX_TILE_ROWS][MAX_TILE_COLS];
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index d523cff..ecc0baf 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -2573,6 +2573,10 @@
seq_params->frame_id_length =
aom_rb_read_literal(rb, 3) + seq_params->delta_frame_id_length + 1;
}
+
+#if CONFIG_MONO_VIDEO
+ seq_params->monochrome = aom_rb_read_bit(rb);
+#endif // CONFIG_MONO_VIDEO
}
#endif // CONFIG_REFERENCE_BUFFER || CONFIG_OBU
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 04cb6e5..0798cfb 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3658,6 +3658,11 @@
wb, seq_params->frame_id_length - seq_params->delta_frame_id_length - 1,
3);
}
+
+#if CONFIG_MONO_VIDEO
+ seq_params->monochrome = cm->monochrome;
+ aom_wb_write_bit(wb, seq_params->monochrome);
+#endif // CONFIG_MONO_VIDEO
}
#endif // CONFIG_REFERENCE_BUFFER || CONFIG_OBU
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index e3630b0..5b0e6ff 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -5516,6 +5516,10 @@
cm->single_tile_decoding = cpi->oxcf.single_tile_decoding;
#endif // CONFIG_EXT_TILE
+#if CONFIG_MONO_VIDEO
+ cm->monochrome = oxcf->monochrome;
+#endif // CONFIG_MONO_VIDEO
+
#if CONFIG_XIPHRC
if (drop_this_frame) {
av1_rc_postencode_update_drop_frame(cpi);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 3584098..d288701 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -304,6 +304,9 @@
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;