Commit 0cfffa7f authored by Luc Trudeau's avatar Luc Trudeau
Browse files

[CFL] Add 4:2:2 Support

When 4:2:2 subsampling is used, both horizontal pixels are added and
shifted left by 1 (instead of a right shift of 2 followed by a left
shift of 3).

Change-Id: Ib84c51cafabe0bd0de02dfe7868278e44d76f6db
parent d8a15a66
......@@ -15,9 +15,13 @@
void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm) {
if (!((cm->subsampling_x == 0 && cm->subsampling_y == 0) ||
(cm->subsampling_x == 1 && cm->subsampling_y == 1))) {
aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"Only 4:4:4 and 4:2:0 are currently supported by CfL");
(cm->subsampling_x == 1 && cm->subsampling_y == 1) ||
(cm->subsampling_x == 1 && cm->subsampling_y == 0))) {
aom_internal_error(
&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"Only 4:4:4, 4:2:2 and 4:2:0 are currently supported by CfL, %d %d "
"subsampling is not supported.\n",
cm->subsampling_x, cm->subsampling_y);
}
memset(&cfl->pred_buf_q3, 0, sizeof(cfl->pred_buf_q3));
cfl->subsampling_x = cm->subsampling_x;
......@@ -388,6 +392,18 @@ static void cfl_luma_subsampling_420(const uint8_t *input, int input_stride,
cfl_luma_subsampling_420_lbd(input, input_stride, output_q3, width, height);
}
static void cfl_luma_subsampling_422(const uint8_t *input, int input_stride,
int16_t *output_q3, int width,
int height) {
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
int left = i << 1;
output_q3[i] = (input[left] + input[left + 1]) << 2;
}
input += input_stride;
output_q3 += MAX_SB_SIZE;
}
}
static void cfl_luma_subsampling_444(const uint8_t *input, int input_stride,
int16_t *output_q3, int width, int height,
int use_hbd) {
......@@ -442,9 +458,15 @@ static INLINE void cfl_store(CFL_CTX *cfl, const uint8_t *input,
} else if (sub_y == 1 && sub_x == 1) {
cfl_luma_subsampling_420(input, input_stride, pred_buf_q3, store_width,
store_height, use_hbd);
} else if (sub_y == 0 && sub_x == 1) {
cfl_luma_subsampling_422(input, input_stride, pred_buf_q3, store_width,
store_height);
} else {
// TODO(ltrudeau) add support for 4:2:2
assert(0); // Unsupported chroma subsampling
fprintf(stderr,
"Only 4:4:4, 4:2:2 and 4:2:0 are currently supported by CfL, %d %d "
"subsampling is not supported.\n",
sub_x, sub_y);
abort();
}
}
......@@ -599,9 +621,6 @@ void cfl_compute_parameters(MACROBLOCKD *const xd, TX_SIZE tx_size) {
cfl->uv_height =
max_intra_block_height(xd, plane_bsize, AOM_PLANE_U, tx_size);
assert(cfl->buf_width <= cfl->uv_width);
assert(cfl->buf_height <= cfl->uv_height);
cfl_dc_pred(xd, plane_bsize);
cfl_subtract_averages(cfl, tx_size);
cfl->are_parameters_computed = 1;
......
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