mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-30 20:54:07 +00:00
Replace accesses to picture->cu_array with picture_get_cu and picture_get_cu_const
This commit is contained in:
parent
821b71910b
commit
2456c65822
|
@ -787,7 +787,7 @@ void encode_coding_tree(encoder_state * const encoder_state,
|
||||||
{
|
{
|
||||||
cabac_data * const cabac = &encoder_state->cabac;
|
cabac_data * const cabac = &encoder_state->cabac;
|
||||||
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
||||||
cu_info *cur_cu = &cur_pic->cu_array[x_ctb + y_ctb * (cur_pic->width_in_lcu << MAX_DEPTH)];
|
const cu_info *cur_cu = picture_get_cu_const(cur_pic, x_ctb, y_ctb);
|
||||||
uint8_t split_flag = GET_SPLITDATA(cur_cu, depth);
|
uint8_t split_flag = GET_SPLITDATA(cur_cu, depth);
|
||||||
uint8_t split_model = 0;
|
uint8_t split_model = 0;
|
||||||
|
|
||||||
|
@ -807,11 +807,11 @@ void encode_coding_tree(encoder_state * const encoder_state,
|
||||||
// Implisit split flag when on border
|
// Implisit split flag when on border
|
||||||
if (!border) {
|
if (!border) {
|
||||||
// Get left and top block split_flags and if they are present and true, increase model number
|
// Get left and top block split_flags and if they are present and true, increase model number
|
||||||
if (x_ctb > 0 && GET_SPLITDATA(&(cur_pic->cu_array[x_ctb - 1 + y_ctb * (cur_pic->width_in_lcu << MAX_DEPTH)]), depth) == 1) {
|
if (x_ctb > 0 && GET_SPLITDATA(picture_get_cu_const(cur_pic, x_ctb - 1, y_ctb), depth) == 1) {
|
||||||
split_model++;
|
split_model++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y_ctb > 0 && GET_SPLITDATA(&(cur_pic->cu_array[x_ctb + (y_ctb - 1) * (cur_pic->width_in_lcu << MAX_DEPTH)]), depth) == 1) {
|
if (y_ctb > 0 && GET_SPLITDATA(picture_get_cu_const(cur_pic, x_ctb, y_ctb - 1), depth) == 1) {
|
||||||
split_model++;
|
split_model++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,11 +846,11 @@ void encode_coding_tree(encoder_state * const encoder_state,
|
||||||
int ui;
|
int ui;
|
||||||
int16_t num_cand = MRG_MAX_NUM_CANDS;
|
int16_t num_cand = MRG_MAX_NUM_CANDS;
|
||||||
// Get left and top skipped flags and if they are present and true, increase context number
|
// Get left and top skipped flags and if they are present and true, increase context number
|
||||||
if (x_ctb > 0 && (&cur_pic->cu_array[x_ctb - 1 + y_ctb * (cur_pic->width_in_lcu << MAX_DEPTH)])->skipped) {
|
if (x_ctb > 0 && (picture_get_cu_const(cur_pic, x_ctb - 1, y_ctb))->skipped) {
|
||||||
ctx_skip++;
|
ctx_skip++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y_ctb > 0 && (&cur_pic->cu_array[x_ctb + (y_ctb - 1) * (cur_pic->width_in_lcu << MAX_DEPTH)])->skipped) {
|
if (y_ctb > 0 && (picture_get_cu_const(cur_pic, x_ctb, y_ctb - 1))->skipped) {
|
||||||
ctx_skip++;
|
ctx_skip++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,15 +1063,15 @@ void encode_coding_tree(encoder_state * const encoder_state,
|
||||||
// 5 EP bins with the full predmode
|
// 5 EP bins with the full predmode
|
||||||
for (j = 0; j < num_pred_units; ++j) {
|
for (j = 0; j < num_pred_units; ++j) {
|
||||||
static const vector2d offset[4] = {{0,0},{1,0},{0,1},{1,1}};
|
static const vector2d offset[4] = {{0,0},{1,0},{0,1},{1,1}};
|
||||||
cu_info *left_cu = 0;
|
const cu_info *left_cu = NULL;
|
||||||
cu_info *above_cu = 0;
|
const cu_info *above_cu = NULL;
|
||||||
|
|
||||||
if (x_ctb > 0) {
|
if (x_ctb > 0) {
|
||||||
left_cu = &cur_pic->cu_array[x_ctb - 1 + y_ctb * (cur_pic->width_in_lcu << MAX_DEPTH)];
|
left_cu = picture_get_cu_const(cur_pic, x_ctb - 1, y_ctb);
|
||||||
}
|
}
|
||||||
// Don't take the above CU across the LCU boundary.
|
// Don't take the above CU across the LCU boundary.
|
||||||
if (y_ctb > 0 && (y_ctb & 7) != 0) {
|
if (y_ctb > 0 && (y_ctb & 7) != 0) {
|
||||||
above_cu = &cur_pic->cu_array[x_ctb + (y_ctb - 1) * (cur_pic->width_in_lcu << MAX_DEPTH)];
|
above_cu = picture_get_cu_const(cur_pic, x_ctb, y_ctb - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
intra_get_dir_luma_predictor((x_ctb<<3) + (offset[j].x<<2),
|
intra_get_dir_luma_predictor((x_ctb<<3) + (offset[j].x<<2),
|
||||||
|
@ -1241,7 +1241,7 @@ static void encode_transform_unit(encoder_state * const encoder_state,
|
||||||
|
|
||||||
int x_cu = x_pu / 2;
|
int x_cu = x_pu / 2;
|
||||||
int y_cu = y_pu / 2;
|
int y_cu = y_pu / 2;
|
||||||
cu_info *cur_cu = &cur_pic->cu_array[x_cu + y_cu * (cur_pic->width_in_lcu << MAX_DEPTH)];
|
const cu_info *cur_cu = picture_get_cu_const(cur_pic, x_cu, y_cu);
|
||||||
|
|
||||||
coefficient coeff_y[LCU_WIDTH*LCU_WIDTH+1];
|
coefficient coeff_y[LCU_WIDTH*LCU_WIDTH+1];
|
||||||
coefficient coeff_u[LCU_WIDTH*LCU_WIDTH>>2];
|
coefficient coeff_u[LCU_WIDTH*LCU_WIDTH>>2];
|
||||||
|
@ -1328,7 +1328,7 @@ void encode_transform_coeff(encoder_state * const encoder_state, int32_t x_pu,in
|
||||||
int32_t x_cu = x_pu / 2;
|
int32_t x_cu = x_pu / 2;
|
||||||
int32_t y_cu = y_pu / 2;
|
int32_t y_cu = y_pu / 2;
|
||||||
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
||||||
cu_info *cur_cu = &cur_pic->cu_array[x_cu + y_cu * (cur_pic->width_in_lcu << MAX_DEPTH)];
|
const cu_info *cur_cu = picture_get_cu_const(cur_pic, x_cu, y_cu);
|
||||||
|
|
||||||
// NxN signifies implicit transform split at the first transform level.
|
// NxN signifies implicit transform split at the first transform level.
|
||||||
// There is a similar implicit split for inter, but it is only used when
|
// There is a similar implicit split for inter, but it is only used when
|
||||||
|
|
18
src/filter.c
18
src/filter.c
|
@ -170,7 +170,7 @@ void filter_deblock_edge_luma(encoder_state * const encoder_state,
|
||||||
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
||||||
const encoder_control * const encoder = encoder_state->encoder_control;
|
const encoder_control * const encoder = encoder_state->encoder_control;
|
||||||
|
|
||||||
cu_info *cu_q = &cur_pic->cu_array[(xpos>>MIN_SIZE) + (ypos>>MIN_SIZE) * (cur_pic->width_in_lcu << MAX_DEPTH)];
|
const cu_info *cu_q = picture_get_cu_const(cur_pic, xpos>>MIN_SIZE, ypos>>MIN_SIZE);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Return if called with a coordinate which is not at CU or TU boundary.
|
// Return if called with a coordinate which is not at CU or TU boundary.
|
||||||
|
@ -190,7 +190,7 @@ void filter_deblock_edge_luma(encoder_state * const encoder_state,
|
||||||
pixel *orig_src = &cur_pic->y_recdata[xpos + ypos*stride];
|
pixel *orig_src = &cur_pic->y_recdata[xpos + ypos*stride];
|
||||||
pixel *src = orig_src;
|
pixel *src = orig_src;
|
||||||
int32_t step = 1;
|
int32_t step = 1;
|
||||||
cu_info *cu_p = NULL;
|
const cu_info *cu_p = NULL;
|
||||||
int16_t x_cu = xpos>>MIN_SIZE,y_cu = ypos>>MIN_SIZE;
|
int16_t x_cu = xpos>>MIN_SIZE,y_cu = ypos>>MIN_SIZE;
|
||||||
int8_t strength = 0;
|
int8_t strength = 0;
|
||||||
|
|
||||||
|
@ -227,9 +227,7 @@ void filter_deblock_edge_luma(encoder_state * const encoder_state,
|
||||||
}
|
}
|
||||||
|
|
||||||
// CU in the side we are filtering, update every 8-pixels
|
// CU in the side we are filtering, update every 8-pixels
|
||||||
cu_p = &cur_pic->cu_array[(x_cu - (dir == EDGE_VER) + (dir == EDGE_HOR ? block_idx>>1 : 0)) +
|
cu_p = picture_get_cu_const(cur_pic, x_cu - (dir == EDGE_VER) + (dir == EDGE_HOR ? block_idx>>1 : 0), y_cu - (dir == EDGE_HOR) + (dir == EDGE_VER ? block_idx>>1 : 0));
|
||||||
(y_cu - (dir == EDGE_HOR) + (dir == EDGE_VER ? block_idx>>1 : 0))
|
|
||||||
* (cur_pic->width_in_lcu << MAX_DEPTH)];
|
|
||||||
// Filter strength
|
// Filter strength
|
||||||
strength = 0;
|
strength = 0;
|
||||||
if(cu_q->type == CU_INTRA || cu_p->type == CU_INTRA) {
|
if(cu_q->type == CU_INTRA || cu_p->type == CU_INTRA) {
|
||||||
|
@ -296,7 +294,7 @@ void filter_deblock_edge_chroma(encoder_state * const encoder_state,
|
||||||
{
|
{
|
||||||
const encoder_control * const encoder = encoder_state->encoder_control;
|
const encoder_control * const encoder = encoder_state->encoder_control;
|
||||||
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
||||||
cu_info *cu_q = &cur_pic->cu_array[(x>>(MIN_SIZE-1)) + (y>>(MIN_SIZE-1)) * (cur_pic->width_in_lcu << MAX_DEPTH)];
|
const cu_info *cu_q = picture_get_cu_const(cur_pic, x>>(MIN_SIZE-1), y>>(MIN_SIZE-1));
|
||||||
|
|
||||||
// Chroma edges that do not lay on a 8x8 grid are not deblocked.
|
// Chroma edges that do not lay on a 8x8 grid are not deblocked.
|
||||||
if (depth >= MAX_DEPTH) {
|
if (depth >= MAX_DEPTH) {
|
||||||
|
@ -323,7 +321,7 @@ void filter_deblock_edge_chroma(encoder_state * const encoder_state,
|
||||||
// Init offset and step to EDGE_HOR
|
// Init offset and step to EDGE_HOR
|
||||||
int32_t offset = stride;
|
int32_t offset = stride;
|
||||||
int32_t step = 1;
|
int32_t step = 1;
|
||||||
cu_info *cu_p = NULL;
|
const cu_info *cu_p = NULL;
|
||||||
int16_t x_cu = x>>(MIN_SIZE-1),y_cu = y>>(MIN_SIZE-1);
|
int16_t x_cu = x>>(MIN_SIZE-1),y_cu = y>>(MIN_SIZE-1);
|
||||||
int8_t strength = 2;
|
int8_t strength = 2;
|
||||||
|
|
||||||
|
@ -348,9 +346,7 @@ void filter_deblock_edge_chroma(encoder_state * const encoder_state,
|
||||||
(dir == EDGE_HOR ? x + blk_idx * 4 : x),
|
(dir == EDGE_HOR ? x + blk_idx * 4 : x),
|
||||||
(dir == EDGE_VER ? y + blk_idx * 4 : y)
|
(dir == EDGE_VER ? y + blk_idx * 4 : y)
|
||||||
};
|
};
|
||||||
cu_p = &cur_pic->cu_array[(x_cu - (dir == EDGE_VER) + (dir == EDGE_HOR ? blk_idx : 0)) +
|
cu_p = picture_get_cu_const(cur_pic, x_cu - (dir == EDGE_VER) + (dir == EDGE_HOR ? blk_idx : 0), y_cu - (dir == EDGE_HOR) + (dir == EDGE_VER ? blk_idx : 0));
|
||||||
(y_cu - (dir == EDGE_HOR) + (dir == EDGE_VER ? blk_idx : 0))
|
|
||||||
* (cur_pic->width_in_lcu << MAX_DEPTH)];
|
|
||||||
|
|
||||||
// Don't deblock the last 4x4 block of the LCU. This will be deblocked
|
// Don't deblock the last 4x4 block of the LCU. This will be deblocked
|
||||||
// when processing the next LCU.
|
// when processing the next LCU.
|
||||||
|
@ -390,7 +386,7 @@ void filter_deblock_edge_chroma(encoder_state * const encoder_state,
|
||||||
void filter_deblock_cu(encoder_state * const encoder_state, int32_t x, int32_t y, int8_t depth, int32_t edge)
|
void filter_deblock_cu(encoder_state * const encoder_state, int32_t x, int32_t y, int8_t depth, int32_t edge)
|
||||||
{
|
{
|
||||||
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
||||||
cu_info *cur_cu = &cur_pic->cu_array[x + y*(cur_pic->width_in_lcu << MAX_DEPTH)];
|
const cu_info *cur_cu = picture_get_cu_const(cur_pic, x, y);
|
||||||
uint8_t split_flag = (cur_cu->depth > depth) ? 1 : 0;
|
uint8_t split_flag = (cur_cu->depth > depth) ? 1 : 0;
|
||||||
uint8_t tr_split = (cur_cu->tr_depth > depth) ? 1 : 0;
|
uint8_t tr_split = (cur_cu->tr_depth > depth) ? 1 : 0;
|
||||||
uint8_t border_x = (cur_pic->width < x*(LCU_WIDTH >> MAX_DEPTH) + (LCU_WIDTH >> depth)) ? 1 : 0;
|
uint8_t border_x = (cur_pic->width < x*(LCU_WIDTH >> MAX_DEPTH) + (LCU_WIDTH >> depth)) ? 1 : 0;
|
||||||
|
|
|
@ -112,7 +112,6 @@ typedef int16_t coefficient;
|
||||||
#define CLIP(low,high,value) MAX((low),MIN((high),(value)))
|
#define CLIP(low,high,value) MAX((low),MIN((high),(value)))
|
||||||
#define SWAP(a,b,swaptype) { swaptype tempval; tempval = a; a = b; b = tempval; }
|
#define SWAP(a,b,swaptype) { swaptype tempval; tempval = a; a = b; b = tempval; }
|
||||||
#define CU_WIDTH_FROM_DEPTH(depth) (LCU_WIDTH >> depth)
|
#define CU_WIDTH_FROM_DEPTH(depth) (LCU_WIDTH >> depth)
|
||||||
#define NO_SCU_IN_LCU(no_lcu) ((no_lcu) << MAX_DEPTH)
|
|
||||||
#define WITHIN(val, min_val, max_val) ((min_val) <= (val) && (val) <= (max_val))
|
#define WITHIN(val, min_val, max_val) ((min_val) <= (val) && (val) <= (max_val))
|
||||||
#define PU_INDEX(x_pu, y_pu) (((x_pu) % 2) + 2 * ((y_pu) % 2))
|
#define PU_INDEX(x_pu, y_pu) (((x_pu) % 2) + 2 * ((y_pu) % 2))
|
||||||
|
|
||||||
|
|
21
src/inter.c
21
src/inter.c
|
@ -43,23 +43,22 @@ void inter_set_block(picture* pic, uint32_t x_cu, uint32_t y_cu, uint8_t depth,
|
||||||
{
|
{
|
||||||
uint32_t x, y;
|
uint32_t x, y;
|
||||||
// Width in smallest CU
|
// Width in smallest CU
|
||||||
int width_in_scu = pic->width_in_lcu<<MAX_DEPTH;
|
|
||||||
int block_scu_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
int block_scu_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
||||||
int tr_depth = (depth == 0 ? 1 : depth);
|
int tr_depth = (depth == 0 ? 1 : depth);
|
||||||
// Loop through all the block in the area of cur_cu
|
// Loop through all the block in the area of cur_cu
|
||||||
for (y = y_cu; y < y_cu + block_scu_width; y++) {
|
for (y = y_cu; y < y_cu + block_scu_width; y++) {
|
||||||
int cu_pos = y * width_in_scu; //!< calculate y-position once, use with every x
|
|
||||||
for (x = x_cu; x < x_cu + block_scu_width; x++) {
|
for (x = x_cu; x < x_cu + block_scu_width; x++) {
|
||||||
|
cu_info * const cu = picture_get_cu(pic, x, y);
|
||||||
// Set all SCU's to this blocks values at the bottom most depth.
|
// Set all SCU's to this blocks values at the bottom most depth.
|
||||||
pic->cu_array[cu_pos + x].depth = depth;
|
cu->depth = depth;
|
||||||
pic->cu_array[cu_pos + x].type = CU_INTER;
|
cu->type = CU_INTER;
|
||||||
pic->cu_array[cu_pos + x].part_size = SIZE_2Nx2N;
|
cu->part_size = SIZE_2Nx2N;
|
||||||
pic->cu_array[cu_pos + x].inter.mode = cur_cu->inter.mode;
|
cu->inter.mode = cur_cu->inter.mode;
|
||||||
pic->cu_array[cu_pos + x].inter.mv[0] = cur_cu->inter.mv[0];
|
cu->inter.mv[0] = cur_cu->inter.mv[0];
|
||||||
pic->cu_array[cu_pos + x].inter.mv[1] = cur_cu->inter.mv[1];
|
cu->inter.mv[1] = cur_cu->inter.mv[1];
|
||||||
pic->cu_array[cu_pos + x].inter.mv_dir = cur_cu->inter.mv_dir;
|
cu->inter.mv_dir = cur_cu->inter.mv_dir;
|
||||||
pic->cu_array[cu_pos + x].inter.mv_ref = cur_cu->inter.mv_ref;
|
cu->inter.mv_ref = cur_cu->inter.mv_ref;
|
||||||
pic->cu_array[cu_pos + x].tr_depth = tr_depth;
|
cu->tr_depth = tr_depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,11 +50,10 @@ const uint8_t intra_hor_ver_dist_thres[5] = {0,7,1,0,0};
|
||||||
void intra_set_block_mode(picture *pic,uint32_t x_cu, uint32_t y_cu, uint8_t depth, uint8_t mode, uint8_t part_mode)
|
void intra_set_block_mode(picture *pic,uint32_t x_cu, uint32_t y_cu, uint8_t depth, uint8_t mode, uint8_t part_mode)
|
||||||
{
|
{
|
||||||
uint32_t x, y;
|
uint32_t x, y;
|
||||||
int width_in_scu = pic->width_in_lcu<<MAX_DEPTH; //!< Width in smallest CU
|
|
||||||
int block_scu_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
int block_scu_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
||||||
|
|
||||||
if (part_mode == SIZE_NxN) {
|
if (part_mode == SIZE_NxN) {
|
||||||
cu_info *cur_cu = &pic->cu_array[x_cu + y_cu * width_in_scu];
|
cu_info *cur_cu = picture_get_cu(pic, x_cu, y_cu);
|
||||||
// Modes are already set.
|
// Modes are already set.
|
||||||
cur_cu->depth = depth;
|
cur_cu->depth = depth;
|
||||||
cur_cu->type = CU_INTRA;
|
cur_cu->type = CU_INTRA;
|
||||||
|
@ -65,7 +64,7 @@ void intra_set_block_mode(picture *pic,uint32_t x_cu, uint32_t y_cu, uint8_t dep
|
||||||
// Loop through all the blocks in the area of cur_cu
|
// Loop through all the blocks in the area of cur_cu
|
||||||
for (y = y_cu; y < y_cu + block_scu_width; y++) {
|
for (y = y_cu; y < y_cu + block_scu_width; y++) {
|
||||||
for (x = x_cu; x < x_cu + block_scu_width; x++) {
|
for (x = x_cu; x < x_cu + block_scu_width; x++) {
|
||||||
cu_info *cur_cu = &pic->cu_array[x + y * width_in_scu];
|
cu_info *cur_cu = picture_get_cu(pic, x_cu, y_cu);
|
||||||
cur_cu->depth = depth;
|
cur_cu->depth = depth;
|
||||||
cur_cu->type = CU_INTRA;
|
cur_cu->type = CU_INTRA;
|
||||||
cur_cu->intra[0].mode = mode;
|
cur_cu->intra[0].mode = mode;
|
||||||
|
@ -111,8 +110,8 @@ pixel intra_get_dc_pred(pixel *pic, uint16_t picwidth, uint8_t width)
|
||||||
* \param preds output buffer for 3 predictions
|
* \param preds output buffer for 3 predictions
|
||||||
* \returns (predictions are found)?1:0
|
* \returns (predictions are found)?1:0
|
||||||
*/
|
*/
|
||||||
int8_t intra_get_dir_luma_predictor(uint32_t x, uint32_t y, int8_t* preds,
|
int8_t intra_get_dir_luma_predictor(const uint32_t x, const uint32_t y, int8_t* preds,
|
||||||
cu_info* cur_cu, cu_info* left_cu, cu_info* above_cu)
|
const cu_info * const cur_cu, const cu_info * const left_cu, const cu_info * const above_cu)
|
||||||
{
|
{
|
||||||
int y_cu = y>>3;
|
int y_cu = y>>3;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
void intra_set_block_mode(picture* pic,uint32_t x_ctb, uint32_t y_ctb, uint8_t depth, uint8_t mode, uint8_t part_mode);
|
void intra_set_block_mode(picture* pic,uint32_t x_ctb, uint32_t y_ctb, uint8_t depth, uint8_t mode, uint8_t part_mode);
|
||||||
|
|
||||||
int8_t intra_get_dir_luma_predictor(uint32_t x, uint32_t y, int8_t* preds,
|
int8_t intra_get_dir_luma_predictor(uint32_t x, uint32_t y, int8_t* preds,
|
||||||
cu_info* cur_cu, cu_info* left_cu, cu_info* above_cu);
|
const cu_info* cur_cu, const cu_info* left_cu, const cu_info* above_cu);
|
||||||
void intra_dc_pred_filtering(pixel* src, int32_t src_stride, pixel* dst, int32_t dst_stride, int32_t width, int32_t height );
|
void intra_dc_pred_filtering(pixel* src, int32_t src_stride, pixel* dst, int32_t dst_stride, int32_t width, int32_t height );
|
||||||
|
|
||||||
void intra_build_reference_border(const encoder_control *encoder, int32_t x_luma, int32_t y_luma, int16_t out_width, pixel *dst, int32_t dst_stride, int8_t chroma, int32_t pic_width, int32_t pic_height, lcu_t *lcu);
|
void intra_build_reference_border(const encoder_control *encoder, int32_t x_luma, int32_t y_luma, int16_t out_width, pixel *dst, int32_t dst_stride, int8_t chroma, int32_t pic_width, int32_t pic_height, lcu_t *lcu);
|
||||||
|
|
|
@ -194,6 +194,20 @@ int picture_free(picture * const pic)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cu_info* picture_get_cu_const(const picture * const pic, unsigned int x_in_scu, unsigned int y_in_scu) {
|
||||||
|
assert(x_in_scu < (pic->width_in_lcu << MAX_DEPTH));
|
||||||
|
assert(y_in_scu < (pic->height_in_lcu << MAX_DEPTH));
|
||||||
|
|
||||||
|
return &pic->cu_array[x_in_scu + y_in_scu * (pic->width_in_lcu << MAX_DEPTH)];
|
||||||
|
}
|
||||||
|
|
||||||
|
cu_info* picture_get_cu(picture * const pic, const unsigned int x_in_scu, const unsigned int y_in_scu) {
|
||||||
|
assert(x_in_scu < (pic->width_in_lcu << MAX_DEPTH));
|
||||||
|
assert(y_in_scu < (pic->height_in_lcu << MAX_DEPTH));
|
||||||
|
|
||||||
|
return &pic->cu_array[x_in_scu + y_in_scu * (pic->width_in_lcu << MAX_DEPTH)];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Calculates image PSNR value
|
* \brief Calculates image PSNR value
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -241,6 +241,9 @@ void picture_blit_coeffs(const coefficient *orig, coefficient *dst,
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
unsigned orig_stride, unsigned dst_stride);
|
unsigned orig_stride, unsigned dst_stride);
|
||||||
|
|
||||||
|
cu_info* picture_get_cu(picture * pic, unsigned int x_in_scu, unsigned int y_in_scu);
|
||||||
|
const cu_info* picture_get_cu_const(const picture * pic, unsigned int x_in_scu, unsigned int y_in_scu);
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned (*cost_16bit_nxn_func)(const pixel *block1, const pixel *block2);
|
typedef unsigned (*cost_16bit_nxn_func)(const pixel *block1, const pixel *block2);
|
||||||
|
|
||||||
|
|
19
src/search.c
19
src/search.c
|
@ -398,8 +398,7 @@ static int search_cu_inter(const encoder_state * const encoder_state, int x, int
|
||||||
|
|
||||||
for (ref_idx = 0; ref_idx < encoder_state->global->ref->used_size; ref_idx++) {
|
for (ref_idx = 0; ref_idx < encoder_state->global->ref->used_size; ref_idx++) {
|
||||||
picture *ref_pic = encoder_state->global->ref->pics[ref_idx];
|
picture *ref_pic = encoder_state->global->ref->pics[ref_idx];
|
||||||
unsigned width_in_scu = NO_SCU_IN_LCU(ref_pic->width_in_lcu);
|
const cu_info *ref_cu = picture_get_cu_const(ref_pic, x_cu, y_cu);
|
||||||
cu_info *ref_cu = &ref_pic->cu_array[y_cu * width_in_scu + x_cu];
|
|
||||||
uint32_t temp_bitcost = 0;
|
uint32_t temp_bitcost = 0;
|
||||||
uint32_t temp_cost = 0;
|
uint32_t temp_cost = 0;
|
||||||
vector2d orig, mv, mvd;
|
vector2d orig, mv, mvd;
|
||||||
|
@ -1143,8 +1142,6 @@ static void init_lcu_t(const encoder_state * const encoder_state, const int x, c
|
||||||
{
|
{
|
||||||
const int x_cu = x >> MAX_DEPTH;
|
const int x_cu = x >> MAX_DEPTH;
|
||||||
const int y_cu = y >> MAX_DEPTH;
|
const int y_cu = y >> MAX_DEPTH;
|
||||||
const int cu_array_width = cur_pic->width_in_lcu << MAX_DEPTH;
|
|
||||||
cu_info *const cu_array = cur_pic->cu_array;
|
|
||||||
|
|
||||||
// Use top-left sub-cu of LCU as pointer to lcu->cu array to make things
|
// Use top-left sub-cu of LCU as pointer to lcu->cu array to make things
|
||||||
// simpler.
|
// simpler.
|
||||||
|
@ -1154,7 +1151,7 @@ static void init_lcu_t(const encoder_state * const encoder_state, const int x, c
|
||||||
if (y_cu > 0) {
|
if (y_cu > 0) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < LCU_CU_WIDTH; ++i) {
|
for (i = 0; i < LCU_CU_WIDTH; ++i) {
|
||||||
const cu_info *from_cu = &cu_array[(x_cu + i) + (y_cu - 1) * cu_array_width];
|
const cu_info *from_cu = picture_get_cu_const(cur_pic, x_cu + i, y_cu - 1);
|
||||||
cu_info *to_cu = &lcu_cu[i - LCU_T_CU_WIDTH];
|
cu_info *to_cu = &lcu_cu[i - LCU_T_CU_WIDTH];
|
||||||
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
||||||
}
|
}
|
||||||
|
@ -1163,21 +1160,21 @@ static void init_lcu_t(const encoder_state * const encoder_state, const int x, c
|
||||||
if (x_cu > 0) {
|
if (x_cu > 0) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < LCU_CU_WIDTH; ++i) {
|
for (i = 0; i < LCU_CU_WIDTH; ++i) {
|
||||||
const cu_info *from_cu = &cu_array[(x_cu - 1) + (y_cu + i) * cu_array_width];
|
const cu_info *from_cu = picture_get_cu_const(cur_pic, x_cu - 1, y_cu + i);
|
||||||
cu_info *to_cu = &lcu_cu[-1 + i * LCU_T_CU_WIDTH];
|
cu_info *to_cu = &lcu_cu[-1 + i * LCU_T_CU_WIDTH];
|
||||||
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Copy top-left CU.
|
// Copy top-left CU.
|
||||||
if (x_cu > 0 && y_cu > 0) {
|
if (x_cu > 0 && y_cu > 0) {
|
||||||
const cu_info *from_cu = &cu_array[(x_cu - 1) + (y_cu - 1) * cu_array_width];
|
const cu_info *from_cu = picture_get_cu_const(cur_pic, x_cu - 1, y_cu - 1);
|
||||||
cu_info *to_cu = &lcu_cu[-1 - LCU_T_CU_WIDTH];
|
cu_info *to_cu = &lcu_cu[-1 - LCU_T_CU_WIDTH];
|
||||||
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy top-right CU.
|
// Copy top-right CU.
|
||||||
if (y_cu > 0 && x + LCU_WIDTH < cur_pic->width) {
|
if (y_cu > 0 && x + LCU_WIDTH < cur_pic->width) {
|
||||||
const cu_info *from_cu = &cu_array[(x_cu + LCU_CU_WIDTH) + (y_cu - 1) * cu_array_width];
|
const cu_info *from_cu = picture_get_cu_const(cur_pic, x_cu + LCU_CU_WIDTH, y_cu - 1);
|
||||||
cu_info *to_cu = &lcu->cu[LCU_T_CU_WIDTH*LCU_T_CU_WIDTH];
|
cu_info *to_cu = &lcu->cu[LCU_T_CU_WIDTH*LCU_T_CU_WIDTH];
|
||||||
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
||||||
}
|
}
|
||||||
|
@ -1237,9 +1234,7 @@ static void copy_lcu_to_cu_data(const encoder_state * const encoder_state, int x
|
||||||
{
|
{
|
||||||
const int x_cu = x_px >> MAX_DEPTH;
|
const int x_cu = x_px >> MAX_DEPTH;
|
||||||
const int y_cu = y_px >> MAX_DEPTH;
|
const int y_cu = y_px >> MAX_DEPTH;
|
||||||
const picture * const cur_pic = encoder_state->tile->cur_pic;
|
picture * const cur_pic = encoder_state->tile->cur_pic;
|
||||||
const int cu_array_width = cur_pic->width_in_lcu << MAX_DEPTH;
|
|
||||||
cu_info *const cu_array = cur_pic->cu_array;
|
|
||||||
|
|
||||||
// Use top-left sub-cu of LCU as pointer to lcu->cu array to make things
|
// Use top-left sub-cu of LCU as pointer to lcu->cu array to make things
|
||||||
// simpler.
|
// simpler.
|
||||||
|
@ -1249,7 +1244,7 @@ static void copy_lcu_to_cu_data(const encoder_state * const encoder_state, int x
|
||||||
for (y = 0; y < LCU_CU_WIDTH; ++y) {
|
for (y = 0; y < LCU_CU_WIDTH; ++y) {
|
||||||
for (x = 0; x < LCU_CU_WIDTH; ++x) {
|
for (x = 0; x < LCU_CU_WIDTH; ++x) {
|
||||||
const cu_info *from_cu = &lcu_cu[x + y * LCU_T_CU_WIDTH];
|
const cu_info *from_cu = &lcu_cu[x + y * LCU_T_CU_WIDTH];
|
||||||
cu_info *to_cu = &cu_array[(x_cu + x) + (y_cu + y) * cu_array_width];
|
cu_info *to_cu = picture_get_cu(cur_pic, x_cu + x, y_cu + y);
|
||||||
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
memcpy(to_cu, from_cu, sizeof(*to_cu));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue