mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-30 12:44:07 +00:00
Merge branch 'inter_residual'
This commit is contained in:
commit
2716b74100
969
src/encoder.c
969
src/encoder.c
File diff suppressed because it is too large
Load diff
|
@ -94,6 +94,8 @@ typedef struct
|
|||
int8_t intra_pred_mode_chroma;
|
||||
int32_t split[4];
|
||||
|
||||
int8_t block_type;
|
||||
|
||||
int32_t x_ctb,y_ctb;
|
||||
|
||||
} transform_info;
|
||||
|
|
20
src/filter.c
20
src/filter.c
|
@ -164,6 +164,7 @@ void filter_deblock_edge_luma(encoder_control *encoder,
|
|||
int32_t step = 1;
|
||||
cu_info *cu_q = &encoder->in.cur_pic->cu_array[MAX_DEPTH][(xpos>>MIN_SIZE) + (ypos>>MIN_SIZE) * (encoder->in.width_in_lcu << MAX_DEPTH)];
|
||||
cu_info *cu_p = 0;
|
||||
int16_t x_cu = xpos>>MIN_SIZE,y_cu = ypos>>MIN_SIZE;
|
||||
int8_t strength = 0;
|
||||
|
||||
|
||||
|
@ -189,11 +190,22 @@ void filter_deblock_edge_luma(encoder_control *encoder,
|
|||
if((block_idx & 1) == 0)
|
||||
{
|
||||
// CU in the side we are filtering, update every 8-pixels
|
||||
cu_p = &encoder->in.cur_pic->cu_array[MAX_DEPTH][((xpos>>MIN_SIZE)-(dir == EDGE_VER)+(dir == EDGE_HOR?block_idx/2:0)) +
|
||||
((ypos>>MIN_SIZE)-(dir == EDGE_HOR)+(dir == EDGE_VER?block_idx/2:0)) * (encoder->in.width_in_lcu << MAX_DEPTH)];
|
||||
cu_p = &encoder->in.cur_pic->cu_array[MAX_DEPTH][(x_cu - (dir == EDGE_VER) + (dir == EDGE_HOR ? block_idx/2 : 0)) +
|
||||
(y_cu - (dir == EDGE_HOR) + (dir == EDGE_VER ? block_idx/2 : 0))
|
||||
* (encoder->in.width_in_lcu << MAX_DEPTH)];
|
||||
// Filter strength
|
||||
strength = ((cu_q->type == CU_INTRA || cu_p->type == CU_INTRA) ? 2 :
|
||||
(((abs(cu_q->inter.mv[0] - cu_p->inter.mv[0]) >= 4) || (abs(cu_q->inter.mv[1] - cu_p->inter.mv[1]) >= 4)) ? 1 : 0));
|
||||
strength = 0;
|
||||
// Intra blocks have strength 2
|
||||
if(cu_q->type == CU_INTRA || cu_p->type == CU_INTRA) {
|
||||
strength = 2;
|
||||
// Non-zero residual and transform boundary
|
||||
} else if((cu_q->residual || cu_p->residual) && (cu_q->depth==0 ? !((dir == EDGE_VER ? y_cu + (block_idx>>1) : x_cu + (block_idx>>1) )&0x3) : 1 ) ) {
|
||||
strength = 1;
|
||||
// Absolute motion vector diff between blocks >= 1 (Integer pixel)
|
||||
} else if((abs(cu_q->inter.mv[0] - cu_p->inter.mv[0]) >= 4) || (abs(cu_q->inter.mv[1] - cu_p->inter.mv[1]) >= 4)) {
|
||||
strength = 1;
|
||||
|
||||
}
|
||||
tc_index = CLIP(0, 51 + 2, (int32_t)(qp + 2*(strength - 1) + (tc_offset_div2 << 1)));
|
||||
tc = g_tc_table_8x8[tc_index] * bitdepth_scale;
|
||||
thr_cut = tc * 10;
|
||||
|
|
|
@ -20,6 +20,29 @@
|
|||
#define PSNRMAX (255.0 * 255.0)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set block residual status
|
||||
* \param pic picture to use
|
||||
* \param x_scu x SCU position (smallest CU)
|
||||
* \param y_scu y SCU position (smallest CU)
|
||||
* \param depth current CU depth
|
||||
* \param residual residual status
|
||||
*/
|
||||
void picture_set_block_residual(picture *pic, uint32_t x_scu, uint32_t y_scu,
|
||||
uint8_t depth, int8_t residual)
|
||||
{
|
||||
uint32_t x, y;
|
||||
int width_in_scu = pic->width_in_lcu << MAX_DEPTH;
|
||||
int block_scu_width = (LCU_WIDTH >> depth) / (LCU_WIDTH >> MAX_DEPTH);
|
||||
|
||||
for (y = y_scu; y < y_scu + block_scu_width; ++y) {
|
||||
int cu_row = y * width_in_scu;
|
||||
for (x = x_scu; x < x_scu + block_scu_width; ++x) {
|
||||
pic->cu_array[MAX_DEPTH][cu_row + x].residual = residual;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set block coded status
|
||||
* \param pic picture to use
|
||||
|
|
|
@ -55,6 +55,7 @@ typedef struct
|
|||
int8_t type;
|
||||
int8_t depth;
|
||||
int8_t coded;
|
||||
int8_t residual;
|
||||
cu_info_intra intra;
|
||||
cu_info_inter inter;
|
||||
} cu_info;
|
||||
|
@ -101,6 +102,8 @@ picture * picture_init(int32_t width, int32_t height,
|
|||
int picture_destroy(picture *pic);
|
||||
void picture_set_block_coded(picture *pic, uint32_t x_scu, uint32_t y_scu,
|
||||
uint8_t depth, int8_t coded);
|
||||
void picture_set_block_residual(picture *pic, uint32_t x_scu, uint32_t y_scu,
|
||||
uint8_t depth, int8_t residual);
|
||||
void picture_set_block_split(picture *pic, uint32_t x_scu, uint32_t y_scu,
|
||||
uint8_t depth, int8_t split);
|
||||
|
||||
|
|
|
@ -756,7 +756,7 @@ void itransform2d(int16_t *block,int16_t *coeff, int8_t block_size, int32_t mode
|
|||
*
|
||||
*/
|
||||
void quant(encoder_control *encoder, int16_t *coef, int16_t *q_coef, int32_t width,
|
||||
int32_t height, uint32_t *ac_sum, int8_t type, int8_t scan_idx )
|
||||
int32_t height, uint32_t *ac_sum, int8_t type, int8_t scan_idx, int8_t block_type )
|
||||
{
|
||||
int8_t use_rdo_q_for_transform_skip = 0;
|
||||
uint32_t log2_block_size = g_convert_to_bit[ width ] + 2;
|
||||
|
@ -786,7 +786,7 @@ void quant(encoder_control *encoder, int16_t *coef, int16_t *q_coef, int32_t wid
|
|||
int32_t n;
|
||||
uint32_t dir = 0;
|
||||
uint32_t log2_tr_size = g_convert_to_bit[ width ] + 2;
|
||||
int32_t scalinglist_type = 3 + (int8_t)("\0\3\1\2"[type]);
|
||||
int32_t scalinglist_type = (block_type == CU_INTRA ? 0 : 3) + (int8_t)("\0\3\1\2"[type]);
|
||||
|
||||
int32_t *quant_coeff = g_quant_coeff[log2_tr_size-2][scalinglist_type][qp_scaled%6];
|
||||
|
||||
|
@ -903,7 +903,7 @@ void quant(encoder_control *encoder, int16_t *coef, int16_t *q_coef, int32_t wid
|
|||
* \brief inverse quantize transformed and quantized coefficents
|
||||
*
|
||||
*/
|
||||
void dequant(encoder_control *encoder, int16_t *q_coef, int16_t *coef, int32_t width, int32_t height,int8_t type)
|
||||
void dequant(encoder_control *encoder, int16_t *q_coef, int16_t *coef, int32_t width, int32_t height,int8_t type, int8_t block_type)
|
||||
{
|
||||
int32_t shift,add,coeff_q;
|
||||
uint32_t log2_tr_size = g_convert_to_bit[ width ] + 2;
|
||||
|
@ -912,7 +912,7 @@ void dequant(encoder_control *encoder, int16_t *q_coef, int16_t *coef, int32_t w
|
|||
int32_t transform_shift = 15 - g_bitdepth - (g_convert_to_bit[ width ] + 2);
|
||||
int32_t qp_scaled;
|
||||
int32_t qp_base = encoder->QP;
|
||||
int32_t scalinglist_type = (/*pcCU->isintra(uiAbsPartIdx)*/1 ? 0 : 3) + (int8_t)("\0\3\1\2"[type]);
|
||||
int32_t scalinglist_type = (block_type == CU_INTRA ? 0 : 3) + (int8_t)("\0\3\1\2"[type]);
|
||||
int32_t *dequant_coef;
|
||||
|
||||
if (type == 0) {
|
||||
|
|
|
@ -23,8 +23,8 @@ extern const uint8_t g_chroma_scale[58];
|
|||
|
||||
|
||||
void quant(encoder_control *encoder, int16_t *coef, int16_t *q_coef, int32_t width,
|
||||
int32_t height, uint32_t *ac_sum, int8_t type, int8_t scan_idx );
|
||||
void dequant(encoder_control *encoder, int16_t *q_coef, int16_t *coef, int32_t width, int32_t height,int8_t type);
|
||||
int32_t height, uint32_t *ac_sum, int8_t type, int8_t scan_idx, int8_t block_type);
|
||||
void dequant(encoder_control *encoder, int16_t *q_coef, int16_t *coef, int32_t width, int32_t height,int8_t type, int8_t block_type);
|
||||
|
||||
void transform2d(int16_t *block,int16_t *coeff, int8_t block_size, int32_t mode);
|
||||
void itransform2d(int16_t *block,int16_t *coeff, int8_t block_size, int32_t mode);
|
||||
|
|
Loading…
Reference in a new issue