mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
parent
46d33d3945
commit
d44d1837bb
|
@ -357,7 +357,7 @@ int32_t context_calc_pattern_sig_ctx(const uint32_t *sig_coeff_group_flag, uint3
|
|||
*/
|
||||
|
||||
int32_t context_get_sig_ctx_inc(int32_t pattern_sig_ctx, uint32_t scan_idx, int32_t pos_x,
|
||||
int32_t pos_y, int32_t block_type, int32_t width, int8_t texture_type)
|
||||
int32_t pos_y, int32_t block_type, int8_t texture_type)
|
||||
{
|
||||
const int32_t ctx_ind_map[16] =
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ uint32_t context_get_sig_coeff_group( uint32_t *sig_coeff_group_flag,uint32_t po
|
|||
|
||||
|
||||
int32_t context_get_sig_ctx_inc(int32_t pattern_sig_ctx,uint32_t scan_idx,int32_t pos_x,
|
||||
int32_t pos_y,int32_t block_type,int32_t width, int8_t texture_type);
|
||||
int32_t pos_y,int32_t block_type, int8_t texture_type);
|
||||
|
||||
// CONTEXTS
|
||||
extern cabac_ctx g_sao_merge_flag_model;
|
||||
|
|
|
@ -377,7 +377,7 @@ void init_encoder_input(encoder_input *input, FILE *inputfile,
|
|||
static void write_aud(encoder_control* encoder)
|
||||
{
|
||||
encode_access_unit_delimiter(encoder);
|
||||
nal_write(encoder->output, 0, AUD_NUT, 0, 1);
|
||||
nal_write(encoder->output, AUD_NUT, 0, 1);
|
||||
bitstream_align(encoder->stream);
|
||||
}
|
||||
|
||||
|
@ -421,23 +421,23 @@ void encode_one_frame(encoder_control* encoder)
|
|||
write_aud(encoder);
|
||||
|
||||
// Video Parameter Set (VPS)
|
||||
nal_write(encoder->output, 0, NAL_VPS_NUT, 0, 1);
|
||||
nal_write(encoder->output, NAL_VPS_NUT, 0, 1);
|
||||
encode_vid_parameter_set(encoder);
|
||||
bitstream_align(encoder->stream);
|
||||
|
||||
// Sequence Parameter Set (SPS)
|
||||
nal_write(encoder->output, 0, NAL_SPS_NUT, 0, 1);
|
||||
nal_write(encoder->output, NAL_SPS_NUT, 0, 1);
|
||||
encode_seq_parameter_set(encoder);
|
||||
bitstream_align(encoder->stream);
|
||||
|
||||
// Picture Parameter Set (PPS)
|
||||
nal_write(encoder->output, 0, NAL_PPS_NUT, 0, 1);
|
||||
nal_write(encoder->output, NAL_PPS_NUT, 0, 1);
|
||||
encode_pic_parameter_set(encoder);
|
||||
bitstream_align(encoder->stream);
|
||||
|
||||
if (encoder->frame == 0) {
|
||||
// Prefix SEI
|
||||
nal_write(encoder->output, 0, PREFIX_SEI_NUT, 0, 0);
|
||||
nal_write(encoder->output, PREFIX_SEI_NUT, 0, 0);
|
||||
encode_prefix_sei_version(encoder);
|
||||
bitstream_align(encoder->stream);
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ void encode_one_frame(encoder_control* encoder)
|
|||
// so I tried to not change it's behavior.
|
||||
int long_start_code = is_radl_frame || encoder->aud_enable ? 0 : 1;
|
||||
|
||||
nal_write(encoder->output, 0,
|
||||
nal_write(encoder->output,
|
||||
is_radl_frame ? NAL_IDR_W_RADL : NAL_TRAIL_R, 0, long_start_code);
|
||||
}
|
||||
|
||||
|
@ -660,7 +660,7 @@ static void add_checksum(encoder_control* encoder)
|
|||
uint32_t checksum_val;
|
||||
unsigned int i;
|
||||
|
||||
nal_write(encoder->output, 0, NAL_SUFFIT_SEI_NUT, 0, 0);
|
||||
nal_write(encoder->output, NAL_SUFFIT_SEI_NUT, 0, 0);
|
||||
|
||||
picture_checksum(encoder->in.cur_pic, checksum);
|
||||
|
||||
|
@ -2398,7 +2398,7 @@ void encode_coeff_nxn(encoder_control *encoder, coefficient *coeff, uint8_t widt
|
|||
last_coeff_y = (uint8_t)(pos_last >> log2_block_size);
|
||||
|
||||
// Code last_coeff_x and last_coeff_y
|
||||
encode_last_significant_xy(encoder, last_coeff_x, last_coeff_y, width, width,
|
||||
encode_last_significant_xy(last_coeff_x, last_coeff_y, width, width,
|
||||
type, scan_mode);
|
||||
|
||||
scan_pos_sig = scan_pos_last;
|
||||
|
@ -2449,7 +2449,7 @@ void encode_coeff_nxn(encoder_control *encoder, coefficient *coeff, uint8_t widt
|
|||
|
||||
if (scan_pos_sig > sub_pos || i == 0 || num_non_zero) {
|
||||
ctx_sig = context_get_sig_ctx_inc(pattern_sig_ctx, scan_mode, pos_x, pos_y,
|
||||
log2_block_size, width, type);
|
||||
log2_block_size, type);
|
||||
cabac.ctx = &baseCtx[ctx_sig];
|
||||
CABAC_BIN(&cabac, sig, "significant_coeff_flag");
|
||||
}
|
||||
|
@ -2555,8 +2555,7 @@ void encode_coeff_nxn(encoder_control *encoder, coefficient *coeff, uint8_t widt
|
|||
|
||||
This method encodes the X and Y component within a block of the last significant coefficient.
|
||||
*/
|
||||
void encode_last_significant_xy(encoder_control *encoder,
|
||||
uint8_t lastpos_x, uint8_t lastpos_y,
|
||||
void encode_last_significant_xy(uint8_t lastpos_x, uint8_t lastpos_y,
|
||||
uint8_t width, uint8_t height,
|
||||
uint8_t type, uint8_t scan)
|
||||
{
|
||||
|
|
|
@ -115,8 +115,8 @@ void encode_access_unit_delimiter(encoder_control* encoder);
|
|||
void encode_prefix_sei_version(encoder_control* encoder);
|
||||
void encode_coding_tree(encoder_control *encoder, uint16_t x_ctb,
|
||||
uint16_t y_ctb, uint8_t depth);
|
||||
void encode_last_significant_xy(encoder_control *encoder, uint8_t lastpos_x,
|
||||
uint8_t lastpos_y, uint8_t width, uint8_t height,
|
||||
void encode_last_significant_xy(uint8_t lastpos_x, uint8_t lastpos_y,
|
||||
uint8_t width, uint8_t height,
|
||||
uint8_t type, uint8_t scan);
|
||||
void encode_coeff_nxn(encoder_control *encoder, int16_t *coeff, uint8_t width,
|
||||
uint8_t type, int8_t scan_mode, int8_t tr_skip);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
/**
|
||||
* \brief Write a Network Abstraction Layer (NAL) packet to the output.
|
||||
*/
|
||||
void nal_write(FILE *output, uint8_t nal_ref, uint8_t nal_type,
|
||||
void nal_write(FILE *output, uint8_t nal_type,
|
||||
uint8_t temporal_id,int long_start_code)
|
||||
{
|
||||
uint8_t byte;
|
||||
|
|
|
@ -92,7 +92,7 @@ enum {
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
void nal_write(FILE *output,uint8_t nal_ref, uint8_t nal_type,
|
||||
void nal_write(FILE *output, uint8_t nal_type,
|
||||
uint8_t temporal_id,int long_start_code);
|
||||
void picture_checksum(const picture *pic,
|
||||
unsigned char checksum_out[][SEI_HASH_MAX_LENGTH]);
|
||||
|
|
|
@ -408,7 +408,7 @@ void rdoq(encoder_control *encoder, coefficient *coef, coefficient *dest_coeff,
|
|||
uint32_t pos_y = blkpos >> log2_block_size;
|
||||
uint32_t pos_x = blkpos - ( pos_y << log2_block_size );
|
||||
uint16_t ctx_sig = (uint16_t)context_get_sig_ctx_inc(pattern_sig_ctx, scan_mode, pos_x, pos_y,
|
||||
log2_block_size, width, type);
|
||||
log2_block_size, type);
|
||||
level = get_coded_level(encoder, &cost_coeff[ scanpos ], &cost_coeff0[ scanpos ], &cost_sig[ scanpos ],
|
||||
level_double, max_abs_level, ctx_sig, one_ctx, abs_ctx, go_rice_param,
|
||||
c1_idx, c2_idx, q_bits, temp, 0, type );
|
||||
|
|
|
@ -265,8 +265,7 @@ static void sao_reconstruct_color(const pixel *rec_data, pixel *new_rec_data,
|
|||
* \param rec Top-left corner of the LCU
|
||||
*/
|
||||
static void sao_calc_band_block_dims(const picture *pic, color_index color_i,
|
||||
const sao_info *sao, vector2d *rec,
|
||||
vector2d *block)
|
||||
vector2d *rec, vector2d *block)
|
||||
{
|
||||
const int is_chroma = (color_i != COLOR_Y ? 1 : 0);
|
||||
int width = pic->width >> is_chroma;
|
||||
|
@ -406,7 +405,7 @@ void sao_reconstruct(picture *pic, const pixel *old_rec,
|
|||
if (sao->type == SAO_TYPE_BAND) {
|
||||
tl.x = 0; tl.y = 0;
|
||||
br.x = 0; br.y = 0;
|
||||
sao_calc_band_block_dims(pic, color_i, sao,&ofs, &block);
|
||||
sao_calc_band_block_dims(pic, color_i, &ofs, &block);
|
||||
}
|
||||
else {
|
||||
sao_calc_edge_block_dims(pic, color_i, sao, &ofs, &tl, &br, &block);
|
||||
|
|
19
src/search.c
19
src/search.c
|
@ -117,7 +117,7 @@ static uint32_t get_mvd_coding_cost(vector2d *mvd)
|
|||
return bitcost;
|
||||
}
|
||||
|
||||
static int calc_mvd_cost(int x, int y, const vector2d *pred,
|
||||
static int calc_mvd_cost(int x, int y,
|
||||
int16_t mv_cand[2][2], int16_t merge_cand[MRG_MAX_NUM_CANDS][3],
|
||||
int16_t num_cand,int32_t ref_idx, uint32_t *bitcost)
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ static unsigned hexagon_search(unsigned depth,
|
|||
unsigned cost = calc_sad(pic, ref, orig->x, orig->y,
|
||||
orig->x + mv.x + pattern->x, orig->y + mv.y + pattern->y,
|
||||
block_width, block_width);
|
||||
cost += calc_mvd_cost(mv.x + pattern->x, mv.y + pattern->y, mv_in_out,mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
cost += calc_mvd_cost(mv.x + pattern->x, mv.y + pattern->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
|
||||
if (cost < best_cost) {
|
||||
best_cost = cost;
|
||||
|
@ -217,7 +217,7 @@ static unsigned hexagon_search(unsigned depth,
|
|||
unsigned cost = calc_sad(pic, ref, orig->x, orig->y,
|
||||
orig->x, orig->y,
|
||||
block_width, block_width);
|
||||
cost += calc_mvd_cost(0, 0, mv_in_out,mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
cost += calc_mvd_cost(0, 0, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
|
||||
// If the 0,0 is better, redo the hexagon around that point.
|
||||
if (cost < best_cost) {
|
||||
|
@ -233,7 +233,7 @@ static unsigned hexagon_search(unsigned depth,
|
|||
orig->x + pattern->x,
|
||||
orig->y + pattern->y,
|
||||
block_width, block_width);
|
||||
cost += calc_mvd_cost(pattern->x, pattern->y, mv_in_out,mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
cost += calc_mvd_cost(pattern->x, pattern->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
|
||||
if (cost < best_cost) {
|
||||
best_cost = cost;
|
||||
|
@ -268,7 +268,7 @@ static unsigned hexagon_search(unsigned depth,
|
|||
orig->x + mv.x + offset->x,
|
||||
orig->y + mv.y + offset->y,
|
||||
block_width, block_width);
|
||||
cost += calc_mvd_cost(mv.x + offset->x, mv.y + offset->y, mv_in_out,mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
cost += calc_mvd_cost(mv.x + offset->x, mv.y + offset->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
|
||||
if (cost < best_cost) {
|
||||
best_cost = cost;
|
||||
|
@ -291,7 +291,7 @@ static unsigned hexagon_search(unsigned depth,
|
|||
orig->x + mv.x + offset->x,
|
||||
orig->y + mv.y + offset->y,
|
||||
block_width, block_width);
|
||||
cost += calc_mvd_cost(mv.x + offset->x, mv.y + offset->y, mv_in_out,mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
cost += calc_mvd_cost(mv.x + offset->x, mv.y + offset->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
|
||||
if (cost > 0 && cost < best_cost) {
|
||||
best_cost = cost;
|
||||
|
@ -347,7 +347,7 @@ static unsigned search_mv_full(unsigned depth,
|
|||
orig->x + x,
|
||||
orig->y + y,
|
||||
block_width, block_width);
|
||||
cost += calc_mvd_cost(x, y, mv_in_out,mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
cost += calc_mvd_cost(x, y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||
if (cost < best_cost) {
|
||||
best_cost = cost;
|
||||
best_bitcost = bitcost;
|
||||
|
@ -724,8 +724,7 @@ static int search_cu_intra(encoder_control *encoder,
|
|||
* coding (bitcost * lambda) and cost for coding coefficients (estimated
|
||||
* here as (coefficient_sum * 1.5) * lambda)
|
||||
*/
|
||||
static int lcu_get_final_cost(encoder_control *encoder,
|
||||
const int x_px, const int y_px,
|
||||
static int lcu_get_final_cost(const int x_px, const int y_px,
|
||||
const int depth, lcu_t *lcu)
|
||||
{
|
||||
cu_info *cur_cu;
|
||||
|
@ -843,7 +842,7 @@ static int search_cu(encoder_control *encoder, int x, int y, int depth, lcu_t wo
|
|||
}
|
||||
}
|
||||
if (cur_cu->type == CU_INTRA || cur_cu->type == CU_INTER) {
|
||||
cost = lcu_get_final_cost(encoder, x, y, depth, &work_tree[depth]);
|
||||
cost = lcu_get_final_cost(x, y, depth, &work_tree[depth]);
|
||||
}
|
||||
|
||||
// Recursively split all the way to max search depth.
|
||||
|
|
Loading…
Reference in a new issue