mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
[isp] Change function calls to cu_loc_t.
This commit is contained in:
parent
9406c5c31d
commit
96df3ffd64
37
src/intra.c
37
src/intra.c
|
@ -969,13 +969,13 @@ static void intra_predict_regular(
|
|||
bool pdpcCondition = (mode == 0 || mode == 1); // Planar and DC
|
||||
if (pdpcCondition && multi_ref_index == 0) // Cannot be used with MRL.
|
||||
{
|
||||
uvg_pdpc_planar_dc(mode, width, log2_width, used_ref, dst);
|
||||
uvg_pdpc_planar_dc(mode, cu_loc, color, used_ref, dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void uvg_intra_build_reference_any(
|
||||
const int_fast8_t log2_width,
|
||||
const cu_loc_t* const cu_loc,
|
||||
const color_t color,
|
||||
const vector2d_t *const luma_px,
|
||||
const vector2d_t *const pic_px,
|
||||
|
@ -984,7 +984,12 @@ void uvg_intra_build_reference_any(
|
|||
const uint8_t multi_ref_idx,
|
||||
uvg_pixel *extra_ref_lines)
|
||||
{
|
||||
assert(log2_width >= 2 && log2_width <= 5);
|
||||
const int width = color == COLOR_Y ? cu_loc->width : cu_loc->chroma_width;
|
||||
const int height = color == COLOR_Y ? cu_loc->height : cu_loc->chroma_height;
|
||||
const int log2_width = uvg_g_convert_to_bit[width] + 2;
|
||||
const int log2_height = uvg_g_convert_to_bit[height] + 2;
|
||||
|
||||
assert((log2_width >= 2 && log2_width <= 5) && (log2_height >= 2 && log2_height <= 5));
|
||||
|
||||
refs->filtered_initialized = false;
|
||||
uvg_pixel *out_left_ref = &refs->ref.left[0];
|
||||
|
@ -992,8 +997,6 @@ void uvg_intra_build_reference_any(
|
|||
|
||||
const uvg_pixel dc_val = 1 << (UVG_BIT_DEPTH - 1); //TODO: add used bitdepth as a variable
|
||||
const int is_chroma = color != COLOR_Y ? 1 : 0;
|
||||
// TODO: height for non-square blocks
|
||||
const int_fast8_t width = 1 << log2_width;
|
||||
|
||||
// Get multi ref index from CU under prediction or reconstrcution. Do not use MRL if not luma
|
||||
const uint8_t multi_ref_index = !is_chroma ? multi_ref_idx : 0;
|
||||
|
@ -1184,7 +1187,7 @@ void uvg_intra_build_reference_any(
|
|||
}
|
||||
|
||||
void uvg_intra_build_reference_inner(
|
||||
const int_fast8_t log2_width,
|
||||
const cu_loc_t* const cu_loc,
|
||||
const color_t color,
|
||||
const vector2d_t *const luma_px,
|
||||
const vector2d_t *const pic_px,
|
||||
|
@ -1194,15 +1197,18 @@ void uvg_intra_build_reference_inner(
|
|||
const uint8_t multi_ref_idx,
|
||||
uvg_pixel* extra_ref_lines)
|
||||
{
|
||||
assert(log2_width >= 2 && log2_width <= 5);
|
||||
const int width = color == COLOR_Y ? cu_loc->width : cu_loc->chroma_width;
|
||||
const int height = color == COLOR_Y ? cu_loc->height : cu_loc->chroma_height;
|
||||
const int log2_width = uvg_g_convert_to_bit[width] + 2;
|
||||
const int log2_height = uvg_g_convert_to_bit[height] + 2;
|
||||
|
||||
assert((log2_width >= 2 && log2_width <= 5) && (log2_height >= 2 && log2_height <= 5));
|
||||
|
||||
refs->filtered_initialized = false;
|
||||
uvg_pixel * __restrict out_left_ref = &refs->ref.left[0];
|
||||
uvg_pixel * __restrict out_top_ref = &refs->ref.top[0];
|
||||
|
||||
const int is_chroma = color != COLOR_Y ? 1 : 0;
|
||||
// TODO: height for non-sqaure blocks
|
||||
const int_fast8_t width = 1 << log2_width;
|
||||
|
||||
// Get multiRefIdx from CU under prediction. Do not use MRL if not luma
|
||||
const uint8_t multi_ref_index = !is_chroma ? multi_ref_idx : 0;
|
||||
|
@ -1366,7 +1372,7 @@ void uvg_intra_build_reference_inner(
|
|||
}
|
||||
|
||||
void uvg_intra_build_reference(
|
||||
const int_fast8_t log2_width,
|
||||
const cu_loc_t* const cu_loc,
|
||||
const color_t color,
|
||||
const vector2d_t *const luma_px,
|
||||
const vector2d_t *const pic_px,
|
||||
|
@ -1380,9 +1386,9 @@ void uvg_intra_build_reference(
|
|||
|
||||
// Much logic can be discarded if not on the edge
|
||||
if (luma_px->x > 0 && luma_px->y > 0) {
|
||||
uvg_intra_build_reference_inner(log2_width, color, luma_px, pic_px, lcu, refs, entropy_sync, multi_ref_idx, extra_ref_lines);
|
||||
uvg_intra_build_reference_inner(cu_loc, color, luma_px, pic_px, lcu, refs, entropy_sync, multi_ref_idx, extra_ref_lines);
|
||||
} else {
|
||||
uvg_intra_build_reference_any(log2_width, color, luma_px, pic_px, lcu, refs, multi_ref_idx, extra_ref_lines);
|
||||
uvg_intra_build_reference_any(cu_loc, color, luma_px, pic_px, lcu, refs, multi_ref_idx, extra_ref_lines);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1513,16 +1519,15 @@ static void intra_recon_tb_leaf(
|
|||
frame->rec->stride, 1);
|
||||
}
|
||||
}
|
||||
uvg_intra_build_reference(log2width, color, &luma_px, &pic_px, lcu, &refs, cfg->wpp, extra_refs, multi_ref_index);
|
||||
|
||||
uvg_pixel pred[32 * 32];
|
||||
|
||||
cu_loc_t loc = {
|
||||
x, y,
|
||||
width, height,
|
||||
width, height,
|
||||
};
|
||||
|
||||
uvg_intra_build_reference(&loc, color, &luma_px, &pic_px, lcu, &refs, cfg->wpp, extra_refs, multi_ref_index);
|
||||
|
||||
uvg_pixel pred[32 * 32];
|
||||
uvg_intra_predict(state, &refs, &loc, color, pred, search_data, lcu, tree_type);
|
||||
|
||||
const int index = lcu_px.x + lcu_px.y * lcu_width;
|
||||
|
|
|
@ -107,7 +107,7 @@ int8_t uvg_intra_get_dir_luma_predictor(
|
|||
* \param multi_ref_idx Multi reference line index for the prediction block.
|
||||
*/
|
||||
void uvg_intra_build_reference(
|
||||
const int_fast8_t log2_width,
|
||||
const cu_loc_t* const cu_loc,
|
||||
const color_t color,
|
||||
const vector2d_t *const luma_px,
|
||||
const vector2d_t *const pic_px,
|
||||
|
|
|
@ -682,22 +682,32 @@ static int search_intra_chroma_rough(
|
|||
int x_px,
|
||||
int y_px,
|
||||
int depth,
|
||||
const uvg_pixel *orig_u,
|
||||
const uvg_pixel *orig_v,
|
||||
int16_t origstride,
|
||||
uvg_intra_references *refs_u,
|
||||
uvg_intra_references *refs_v,
|
||||
const vector2d_t* const lcu_px,
|
||||
intra_search_data_t* chroma_data,
|
||||
lcu_t* lcu,
|
||||
int8_t luma_mode,
|
||||
enum uvg_tree_type tree_type)
|
||||
{
|
||||
assert(depth != 4 || (x_px & 4 && y_px & 4));
|
||||
const int_fast8_t log2_width_c = MAX(LOG2_LCU_WIDTH - depth - 1, 2);
|
||||
const vector2d_t pic_px = { state->tile->frame->width, state->tile->frame->height };
|
||||
const vector2d_t luma_px = { x_px & ~7, y_px & ~7 };
|
||||
const int width = 1 << log2_width_c;
|
||||
const int height = width; // TODO: height for non-square blocks
|
||||
|
||||
const unsigned width = MAX(LCU_WIDTH_C >> depth, TR_MIN_WIDTH);
|
||||
const cu_loc_t loc = { luma_px.x, luma_px.y, width, height, width, height };
|
||||
|
||||
uvg_intra_references refs_u;
|
||||
uvg_intra_build_reference(&loc, COLOR_U, &luma_px, &pic_px, lcu, &refs_u, state->encoder_control->cfg.wpp, NULL, 0);
|
||||
|
||||
uvg_intra_references refs_v;
|
||||
uvg_intra_build_reference(&loc, COLOR_V, &luma_px, &pic_px, lcu, &refs_v, state->encoder_control->cfg.wpp, NULL, 0);
|
||||
|
||||
vector2d_t lcu_cpx = { (lcu_px->x & ~7) / 2, (lcu_px->y & ~7) / 2 };
|
||||
uvg_pixel* orig_u = &lcu->ref.u[lcu_cpx.x + lcu_cpx.y * LCU_WIDTH_C];
|
||||
uvg_pixel* orig_v = &lcu->ref.v[lcu_cpx.x + lcu_cpx.y * LCU_WIDTH_C];
|
||||
|
||||
//cost_pixel_nxn_func *const sad_func = uvg_pixels_get_sad_func(width);
|
||||
cu_loc_t loc = { x_px & ~7, y_px & ~7, width, width, width, width };
|
||||
|
||||
uvg_pixel _pred[32 * 32 + SIMD_ALIGNMENT];
|
||||
uvg_pixel *pred = ALIGNED_POINTER(_pred, SIMD_ALIGNMENT);
|
||||
|
@ -705,12 +715,12 @@ static int search_intra_chroma_rough(
|
|||
uvg_pixel _orig_block[32 * 32 + SIMD_ALIGNMENT];
|
||||
uvg_pixel *orig_block = ALIGNED_POINTER(_orig_block, SIMD_ALIGNMENT);
|
||||
|
||||
uvg_pixels_blit(orig_u, orig_block, width, width, origstride, width);
|
||||
uvg_pixels_blit(orig_u, orig_block, width, width, LCU_WIDTH_C, width);
|
||||
int modes_count = (state->encoder_control->cfg.cclm ? 8 : 5);
|
||||
for (int i = 0; i < modes_count; ++i) {
|
||||
const int8_t mode_chroma = chroma_data[i].pred_cu.intra.mode_chroma;
|
||||
if (mode_chroma == luma_mode || mode_chroma == 0 || mode_chroma >= 81) continue;
|
||||
uvg_intra_predict(state, refs_u, &loc, COLOR_U, pred, &chroma_data[i], lcu, tree_type);
|
||||
uvg_intra_predict(state, &refs_u, &loc, COLOR_U, pred, &chroma_data[i], lcu, tree_type);
|
||||
//costs[i] += get_cost(encoder_state, pred, orig_block, satd_func, sad_func, width);
|
||||
switch (width) {
|
||||
case 4: chroma_data[i].cost += uvg_satd_4x4(pred, orig_block);
|
||||
|
@ -725,11 +735,11 @@ static int search_intra_chroma_rough(
|
|||
}
|
||||
}
|
||||
|
||||
uvg_pixels_blit(orig_v, orig_block, width, width, origstride, width);
|
||||
uvg_pixels_blit(orig_v, orig_block, width, width, LCU_WIDTH_C, width);
|
||||
for (int i = 0; i < modes_count; ++i) {
|
||||
const int8_t mode_chroma = chroma_data[i].pred_cu.intra.mode_chroma;
|
||||
if (mode_chroma == luma_mode || mode_chroma == 0 || mode_chroma >= 81) continue;
|
||||
uvg_intra_predict(state, refs_v, &loc, COLOR_V, pred, &chroma_data[i], lcu, tree_type);
|
||||
uvg_intra_predict(state, &refs_v, &loc, COLOR_V, pred, &chroma_data[i], lcu, tree_type);
|
||||
//costs[i] += get_cost(encoder_state, pred, orig_block, satd_func, sad_func, width);
|
||||
switch (width) {
|
||||
case 4: chroma_data[i].cost += uvg_satd_4x4(pred, orig_block);
|
||||
|
@ -1270,8 +1280,15 @@ static void get_rough_cost_for_2n_modes(
|
|||
#define PARALLEL_BLKS 2
|
||||
assert(num_modes % 2 == 0 && "passing odd number of modes to get_rough_cost_for_2n_modes");
|
||||
const int width = cu_loc->width;
|
||||
cost_pixel_nxn_multi_func* satd_dual_func = uvg_pixels_get_satd_dual_func(width);
|
||||
cost_pixel_nxn_multi_func* sad_dual_func = uvg_pixels_get_sad_dual_func(width);
|
||||
const int height = cu_loc->height;
|
||||
cost_pixel_nxn_multi_func* satd_dual_func;
|
||||
cost_pixel_nxn_multi_func* sad_dual_func;
|
||||
if (width == height) {
|
||||
satd_dual_func = uvg_pixels_get_satd_dual_func(width);
|
||||
sad_dual_func = uvg_pixels_get_sad_dual_func(width);
|
||||
} else {
|
||||
assert(false && "Joose promised to fix this.");
|
||||
}
|
||||
|
||||
uvg_pixel _preds[PARALLEL_BLKS * MIN(LCU_WIDTH, 64)* MIN(LCU_WIDTH, 64)+ SIMD_ALIGNMENT];
|
||||
pred_buffer preds = ALIGNED_POINTER(_preds, SIMD_ALIGNMENT);
|
||||
|
@ -1447,6 +1464,10 @@ int8_t uvg_search_intra_chroma_rdo(
|
|||
{
|
||||
const bool reconstruct_chroma = (depth != 4) || (x_px & 4 && y_px & 4);
|
||||
|
||||
int log2_width = MAX(LOG2_LCU_WIDTH - depth - 1, 2);
|
||||
int8_t width = 1 << log2_width;
|
||||
int8_t height = 1 << log2_width;
|
||||
const cu_loc_t loc = { x_px & ~7, y_px & ~7, width, height, width, height };
|
||||
|
||||
uvg_intra_references refs[2];
|
||||
const vector2d_t luma_px = { x_px & ~7, y_px & ~7 };
|
||||
|
@ -1457,16 +1478,13 @@ int8_t uvg_search_intra_chroma_rdo(
|
|||
|
||||
|
||||
if (reconstruct_chroma) {
|
||||
int log2_width = MAX(LOG2_LCU_WIDTH - depth - 1, 2);
|
||||
uvg_intra_build_reference(log2_width, COLOR_U, &luma_px, &pic_px, lcu, &refs[0], state->encoder_control->cfg.wpp, NULL, 0);
|
||||
uvg_intra_build_reference(log2_width, COLOR_V, &luma_px, &pic_px, lcu, &refs[1], state->encoder_control->cfg.wpp, NULL, 0);
|
||||
uvg_intra_build_reference(&loc, COLOR_U, &luma_px, &pic_px, lcu, &refs[0], state->encoder_control->cfg.wpp, NULL, 0);
|
||||
uvg_intra_build_reference(&loc, COLOR_V, &luma_px, &pic_px, lcu, &refs[1], state->encoder_control->cfg.wpp, NULL, 0);
|
||||
|
||||
const vector2d_t lcu_px = { SUB_SCU(x_px), SUB_SCU(y_px) };
|
||||
cabac_data_t temp_cabac;
|
||||
memcpy(&temp_cabac, &state->search_cabac, sizeof(cabac_data_t));
|
||||
int8_t width = 1 << log2_width;
|
||||
int8_t height = 1 << log2_width;
|
||||
const cu_loc_t loc = { x_px &~7, y_px & ~7, width, height, width, height};
|
||||
|
||||
const int offset = ((lcu_px.x & ~7) >> 1) + ((lcu_px.y & ~7) >> 1)* LCU_WIDTH_C;
|
||||
|
||||
int lfnst_modes_to_check[3];
|
||||
|
@ -1659,26 +1677,10 @@ int8_t uvg_search_cu_intra_chroma(
|
|||
// num_modes is 0.is 0.
|
||||
|
||||
if(state->encoder_control->cfg.cclm && 0){
|
||||
const int_fast8_t log2_width_c = MAX(LOG2_LCU_WIDTH - depth - 1, 2);
|
||||
const vector2d_t pic_px = { state->tile->frame->width, state->tile->frame->height };
|
||||
const vector2d_t luma_px = { x_px & ~7, y_px & ~7};
|
||||
|
||||
uvg_intra_references refs_u;
|
||||
uvg_intra_build_reference(log2_width_c, COLOR_U, &luma_px, &pic_px, lcu, &refs_u, state->encoder_control->cfg.wpp, NULL, 0);
|
||||
|
||||
uvg_intra_references refs_v;
|
||||
uvg_intra_build_reference(log2_width_c, COLOR_V, &luma_px, &pic_px, lcu, &refs_v, state->encoder_control->cfg.wpp, NULL, 0);
|
||||
|
||||
vector2d_t lcu_cpx = { (lcu_px.x & ~7) / 2, (lcu_px.y & ~7) / 2 };
|
||||
uvg_pixel *ref_u = &lcu->ref.u[lcu_cpx.x + lcu_cpx.y * LCU_WIDTH_C];
|
||||
uvg_pixel *ref_v = &lcu->ref.v[lcu_cpx.x + lcu_cpx.y * LCU_WIDTH_C];
|
||||
|
||||
|
||||
num_modes = search_intra_chroma_rough(state, x_px, y_px, depth,
|
||||
ref_u,
|
||||
ref_v,
|
||||
LCU_WIDTH_C,
|
||||
&refs_u,
|
||||
&refs_v,
|
||||
&lcu_px,
|
||||
chroma_data,
|
||||
lcu,
|
||||
intra_mode,
|
||||
|
@ -1819,7 +1821,7 @@ void uvg_search_cu_intra(
|
|||
int8_t num_cand = uvg_intra_get_dir_luma_predictor(x_px, y_px, candidate_modes, cur_cu, left_cu, above_cu);
|
||||
|
||||
if (depth > 0) {
|
||||
uvg_intra_build_reference(log2_width, COLOR_Y, &luma_px, &pic_px, lcu, refs, state->encoder_control->cfg.wpp, NULL, 0);
|
||||
uvg_intra_build_reference(&cu_loc, COLOR_Y, &luma_px, &pic_px, lcu, refs, state->encoder_control->cfg.wpp, NULL, 0);
|
||||
}
|
||||
|
||||
// The maximum number of possible MIP modes depend on block size & shape
|
||||
|
@ -1887,7 +1889,7 @@ void uvg_search_cu_intra(
|
|||
frame->rec->stride, 1);
|
||||
}
|
||||
}
|
||||
uvg_intra_build_reference(log2_width, COLOR_Y, &luma_px, &pic_px, lcu, &refs[line], state->encoder_control->cfg.wpp, extra_refs, line);
|
||||
uvg_intra_build_reference(&cu_loc, COLOR_Y, &luma_px, &pic_px, lcu, &refs[line], state->encoder_control->cfg.wpp, extra_refs, line);
|
||||
for(int i = 1; i < INTRA_MPM_COUNT; i++) {
|
||||
num_mrl_modes++;
|
||||
const int index = (i - 1) + (INTRA_MPM_COUNT -1)*(line-1) + number_of_modes;
|
||||
|
|
|
@ -129,8 +129,8 @@ static void uvg_angular_pred_generic(
|
|||
// Sample displacement per column in fractions of 32.
|
||||
const int_fast8_t sample_disp = (mode_disp < 0 ? -1 : 1) * modedisp2sampledisp[abs(mode_disp)];
|
||||
|
||||
// ISP_TODO: replace latter width with height
|
||||
int scale = MIN(2, log2_width - pre_scale[abs(mode_disp)]);
|
||||
const int side_size = vertical_mode ? log2_height : log2_width;
|
||||
int scale = MIN(2, side_size - pre_scale[abs(mode_disp)]);
|
||||
|
||||
// Pointer for the reference we are interpolating from.
|
||||
uvg_pixel *ref_main;
|
||||
|
@ -524,25 +524,26 @@ static void uvg_intra_pred_filtered_dc_generic(
|
|||
|
||||
/**
|
||||
* \brief Position Dependent Prediction Combination for Planar and DC modes.
|
||||
* \param log2_width Log2 of width, range 2..5.
|
||||
* \param width Block width matching log2_width.
|
||||
* \param cu_loc CU location and size data.
|
||||
* \param used_ref Pointer used reference pixel struct.
|
||||
* \param dst Buffer of size width*width.
|
||||
*/
|
||||
static void uvg_pdpc_planar_dc_generic(
|
||||
const int mode,
|
||||
const int width,
|
||||
const int log2_width,
|
||||
const cu_loc_t* const cu_loc,
|
||||
const color_t color,
|
||||
const uvg_intra_ref *const used_ref,
|
||||
uvg_pixel *const dst)
|
||||
{
|
||||
assert(mode == 0 || mode == 1); // planar or DC
|
||||
const int width = color == COLOR_Y ? cu_loc->width : cu_loc->chroma_width;
|
||||
const int height = color == COLOR_Y ? cu_loc->height : cu_loc->chroma_height;
|
||||
const int log2_width = uvg_g_convert_to_bit[width] + 2;
|
||||
const int log2_height = uvg_g_convert_to_bit[height] + 2;
|
||||
|
||||
// TODO: replace latter log2_width with log2_height
|
||||
const int scale = ((log2_width - 2 + log2_width - 2 + 2) >> 2);
|
||||
const int scale = (log2_width + log2_height - 2) >> 2;
|
||||
|
||||
// TODO: replace width with height
|
||||
for (int y = 0; y < width; y++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
int wT = 32 >> MIN(31, ((y << 1) >> scale));
|
||||
for (int x = 0; x < width; x++) {
|
||||
int wL = 32 >> MIN(31, ((x << 1) >> scale));
|
||||
|
|
|
@ -69,8 +69,8 @@ typedef void (intra_pred_filtered_dc_func)(
|
|||
|
||||
typedef void (pdpc_planar_dc_func)(
|
||||
const int mode,
|
||||
const int width,
|
||||
const int log2_width,
|
||||
const cu_loc_t* const cu_loc,
|
||||
const color_t color,
|
||||
const uvg_intra_ref *const used_ref,
|
||||
uvg_pixel *const dst);
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ typedef struct uvg_config
|
|||
/** \brief Flag to enable/disable open GOP configuration */
|
||||
int8_t open_gop;
|
||||
|
||||
int32_t vaq; /** \brief Enable variance adaptive quantization*/
|
||||
int32_t vaq; /** \brief Enable variance adaptive quantization*/
|
||||
|
||||
/** \brief Type of scaling lists to use */
|
||||
int8_t scaling_list;
|
||||
|
|
Loading…
Reference in a new issue