memset(&cfl->recon_buf_q3, 0, sizeof(cfl->recon_buf_q3));
memset(&cfl->ac_buf_q3, 0, sizeof(cfl->ac_buf_q3));
cfl->subsampling_x = seq_params->subsampling_x;
cfl->subsampling_y = seq_params->subsampling_y;
cfl->are_parameters_computed = 0;
cfl->store_y = 0; // The DC_PRED cache is disabled by default and is only enabled in // cfl_rd_pick_alpha
clear_cfl_dc_pred_cache_flags(cfl);
}
// Due to frame boundary issues, it is possible that the total area covered by // chroma exceeds that of luma. When this happens, we fill the missing pixels by // repeating the last columns and/or rows. static inline void cfl_pad(CFL_CTX *cfl, int width, int height) { const int diff_width = width - cfl->buf_width; const int diff_height = height - cfl->buf_height;
static inline void cfl_predict_lbd_c(const int16_t *ac_buf_q3, uint8_t *dst,
int dst_stride, int alpha_q3, int width,
int height) {
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
dst[i] = clip_pixel(get_scaled_luma_q0(alpha_q3, ac_buf_q3[i]) + dst[i]);
}
dst += dst_stride;
ac_buf_q3 += CFL_BUF_LINE;
}
}
CFL_PREDICT_FN(c, lbd)
#if CONFIG_AV1_HIGHBITDEPTH static inline void cfl_predict_hbd_c(const int16_t *ac_buf_q3, uint16_t *dst,
int dst_stride, int alpha_q3,
int bit_depth, int width, int height) {
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
dst[i] = clip_pixel_highbd(
get_scaled_luma_q0(alpha_q3, ac_buf_q3[i]) + dst[i], bit_depth);
}
dst += dst_stride;
ac_buf_q3 += CFL_BUF_LINE;
}
}
CFL_PREDICT_FN(c, hbd) #endif
staticvoid cfl_compute_parameters(MACROBLOCKD *const xd, TX_SIZE tx_size) {
CFL_CTX *const cfl = &xd->cfl; // Do not call cfl_compute_parameters multiple time on the same values.
assert(cfl->are_parameters_computed == 0);
staticvoid cfl_luma_subsampling_420_lbd_c(const uint8_t *input,
int input_stride,
uint16_t *output_q3, int width,
int height) {
for (int j = 0; j < height; j += 2) {
for (int i = 0; i < width; i += 2) { const int bot = i + input_stride;
output_q3[i >> 1] =
(input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1;
}
input += input_stride << 1;
output_q3 += CFL_BUF_LINE;
}
}
staticvoid cfl_luma_subsampling_422_lbd_c(const uint8_t *input,
int input_stride,
uint16_t *output_q3, int width,
int height) {
assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE);
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i += 2) {
output_q3[i >> 1] = (input[i] + input[i + 1]) << 2;
}
input += input_stride;
output_q3 += CFL_BUF_LINE;
}
}
staticvoid cfl_luma_subsampling_444_lbd_c(const uint8_t *input,
int input_stride,
uint16_t *output_q3, int width,
int height) {
assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE);
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
output_q3[i] = input[i] << 3;
}
input += input_stride;
output_q3 += CFL_BUF_LINE;
}
}
#if CONFIG_AV1_HIGHBITDEPTH staticvoid cfl_luma_subsampling_420_hbd_c(const uint16_t *input,
int input_stride,
uint16_t *output_q3, int width,
int height) {
for (int j = 0; j < height; j += 2) {
for (int i = 0; i < width; i += 2) { const int bot = i + input_stride;
output_q3[i >> 1] =
(input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1;
}
input += input_stride << 1;
output_q3 += CFL_BUF_LINE;
}
}
staticvoid cfl_luma_subsampling_422_hbd_c(const uint16_t *input,
int input_stride,
uint16_t *output_q3, int width,
int height) {
assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE);
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i += 2) {
output_q3[i >> 1] = (input[i] + input[i + 1]) << 2;
}
input += input_stride;
output_q3 += CFL_BUF_LINE;
}
}
staticvoid cfl_luma_subsampling_444_hbd_c(const uint16_t *input,
int input_stride,
uint16_t *output_q3, int width,
int height) {
assert((height - 1) * CFL_BUF_LINE + width <= CFL_BUF_SQUARE);
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
output_q3[i] = input[i] << 3;
}
input += input_stride;
output_q3 += CFL_BUF_LINE;
}
} #endif
CFL_GET_SUBSAMPLE_FUNCTION(c)
#if CONFIG_AV1_HIGHBITDEPTH static inline cfl_subsample_hbd_fn cfl_subsampling_hbd(TX_SIZE tx_size,
int sub_x, int sub_y) {
if (sub_x == 1) {
if (sub_y == 1) { return cfl_get_luma_subsampling_420_hbd(tx_size);
} return cfl_get_luma_subsampling_422_hbd(tx_size);
} return cfl_get_luma_subsampling_444_hbd(tx_size);
} #endif
static inline cfl_subsample_lbd_fn cfl_subsampling_lbd(TX_SIZE tx_size,
int sub_x, int sub_y) {
if (sub_x == 1) {
if (sub_y == 1) { return cfl_get_luma_subsampling_420_lbd(tx_size);
} return cfl_get_luma_subsampling_422_lbd(tx_size);
} return cfl_get_luma_subsampling_444_lbd(tx_size);
}
staticvoid cfl_store(CFL_CTX *cfl, const uint8_t *input, int input_stride,
int row, int col, TX_SIZE tx_size, int use_hbd) { const int width = tx_size_wide[tx_size]; const int height = tx_size_high[tx_size]; const int tx_off_log2 = MI_SIZE_LOG2; const int sub_x = cfl->subsampling_x; const int sub_y = cfl->subsampling_y; const int store_row = row << (tx_off_log2 - sub_y); const int store_col = col << (tx_off_log2 - sub_x); const int store_height = height >> sub_y; const int store_width = width >> sub_x;
// Invalidate current parameters
cfl->are_parameters_computed = 0;
// Store the surface of the pixel buffer that was written to, this way we // can manage chroma overrun (e.g. when the chroma surfaces goes beyond the // frame boundary)
if (col == 0 && row == 0) {
cfl->buf_width = store_width;
cfl->buf_height = store_height;
} else {
cfl->buf_width = OD_MAXI(store_col + store_width, cfl->buf_width);
cfl->buf_height = OD_MAXI(store_row + store_height, cfl->buf_height);
}
// Check that we will remain inside the pixel buffer.
assert(store_row + store_height <= CFL_BUF_LINE);
assert(store_col + store_width <= CFL_BUF_LINE);
// Store the input into the CfL pixel buffer
uint16_t *recon_buf_q3 =
cfl->recon_buf_q3 + (store_row * CFL_BUF_LINE + store_col); #if CONFIG_AV1_HIGHBITDEPTH
if (use_hbd) {
cfl_subsampling_hbd(tx_size, sub_x, sub_y)(CONVERT_TO_SHORTPTR(input),
input_stride, recon_buf_q3);
} else {
cfl_subsampling_lbd(tx_size, sub_x, sub_y)(input, input_stride,
recon_buf_q3);
} #else
(void)use_hbd;
cfl_subsampling_lbd(tx_size, sub_x, sub_y)(input, input_stride, recon_buf_q3); #endif
}
// Adjust the row and column of blocks smaller than 8X8, as chroma-referenced // and non-chroma-referenced blocks are stored together in the CfL buffer. static inline void sub8x8_adjust_offset(const CFL_CTX *cfl, int mi_row,
int mi_col, int *row_out,
int *col_out) { // Increment row index for bottom: 8x4, 16x4 or both bottom 4x4s.
if ((mi_row & 0x01) && cfl->subsampling_y) {
assert(*row_out == 0);
(*row_out)++;
}
// Increment col index for right: 4x8, 4x16 or both right 4x4s.
if ((mi_col & 0x01) && cfl->subsampling_x) {
assert(*col_out == 0);
(*col_out)++;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.