mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Merge branches 'coverity-fix-5', 'coverity-fix-6', 'coverity-fix-7', 'coverity-fix-8', 'coverity-fix-9', 'coverity-fix-10', 'coverity-fix-11', 'coverity-fix-12', 'coverity-fix-13' and 'coverity-fix-14' into coverity-fixes2
This commit is contained in:
parent
7a551bece5
cc980fb815
17bdc82b5e
e225c5b302
08d079773f
80cbda364b
41d9889e28
2276e0028f
ed670f4185
62285c405c
commit
c3b42291e1
|
@ -61,16 +61,16 @@ void printf_bitstream(char *msg, ...)
|
|||
|
||||
const bit_table_t *g_exp_table;
|
||||
|
||||
//From wikipedia
|
||||
//http://en.wikipedia.org/wiki/Binary_logarithm#Algorithm
|
||||
static int floor_log2(unsigned int n) {
|
||||
assert(n != 0);
|
||||
|
||||
int pos = 0;
|
||||
if (n >= 1<<16) { n >>= 16; pos += 16; }
|
||||
if (n >= 1<< 8) { n >>= 8; pos += 8; }
|
||||
if (n >= 1<< 4) { n >>= 4; pos += 4; }
|
||||
if (n >= 1<< 2) { n >>= 2; pos += 2; }
|
||||
if (n >= 1<< 1) { pos += 1; }
|
||||
return ((n == 0) ? (-1) : pos);
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -126,7 +126,7 @@ static int encoder_state_config_slice_init(encoder_state_t * const state,
|
|||
}
|
||||
}
|
||||
assert(slice_found);
|
||||
if (!slice_found) return 0;
|
||||
|
||||
state->slice->start_in_ts = start_address_in_ts;
|
||||
state->slice->end_in_ts = end_address_in_ts;
|
||||
|
||||
|
@ -459,12 +459,13 @@ int encoder_state_init(encoder_state_t * const child_state, encoder_state_t * co
|
|||
|
||||
if (new_child) {
|
||||
child_state->children = realloc(child_state->children, sizeof(encoder_state_t) * (2+child_count));
|
||||
child_state->children[1+child_count].encoder_control = NULL;
|
||||
if (!child_state->children) {
|
||||
fprintf(stderr, "Failed to allocate memory for children...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
child_state->children[1 + child_count].encoder_control = NULL;
|
||||
|
||||
//Fix children parent (since we changed the address), except for the last one which is not ready yet
|
||||
{
|
||||
int i, j;
|
||||
|
|
|
@ -246,9 +246,6 @@ static void encoder_state_worker_encode_lcu(void * opaque) {
|
|||
sao_info_t *sao_top_chroma = lcu->position.y != 0 ? &frame->sao_chroma[(lcu->position.y - 1) * stride + lcu->position.x] : NULL;
|
||||
sao_info_t *sao_left_chroma = lcu->position.x != 0 ? &frame->sao_chroma[lcu->position.y * stride + lcu->position.x - 1] : NULL;
|
||||
|
||||
init_sao_info(sao_luma);
|
||||
init_sao_info(sao_chroma);
|
||||
|
||||
sao_search_luma(state, frame, lcu->position.x, lcu->position.y, sao_luma, sao_top_luma, sao_left_luma, merge_cost_luma);
|
||||
sao_search_chroma(state, frame, lcu->position.x, lcu->position.y, sao_chroma, sao_top_chroma, sao_left_chroma, merge_cost_chroma);
|
||||
|
||||
|
@ -1649,6 +1646,8 @@ coeff_scan_order_t get_scan_order(int8_t cu_type, int intra_mode, int depth)
|
|||
static void encode_transform_unit(encoder_state_t * const state,
|
||||
int x_pu, int y_pu, int depth)
|
||||
{
|
||||
assert(depth >= 1 && depth <= MAX_PU_DEPTH);
|
||||
|
||||
const videoframe_t * const frame = state->tile->frame;
|
||||
uint8_t width = LCU_WIDTH >> depth;
|
||||
uint8_t width_c = (depth == MAX_PU_DEPTH ? width : width / 2);
|
||||
|
|
|
@ -741,16 +741,13 @@ uint8_t inter_get_merge_cand(const encoder_state_t * const state, int32_t x, int
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_TEMPORAL_MVP
|
||||
if(candidates < AMVP_MAX_NUM_CANDS) {
|
||||
//TODO: add temporal mv predictor
|
||||
}
|
||||
#endif
|
||||
|
||||
if (candidates == MRG_MAX_NUM_CANDS) return MRG_MAX_NUM_CANDS;
|
||||
|
||||
if (state->global->slicetype == SLICE_B) {
|
||||
if (candidates < MRG_MAX_NUM_CANDS && state->global->slicetype == SLICE_B) {
|
||||
#define NUM_PRIORITY_LIST 12;
|
||||
static const uint8_t priorityList0[] = { 0, 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3 };
|
||||
static const uint8_t priorityList1[] = { 1, 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2 };
|
||||
|
@ -783,11 +780,9 @@ uint8_t inter_get_merge_cand(const encoder_state_t * const state, int32_t x, int
|
|||
}
|
||||
}
|
||||
|
||||
if (candidates == MRG_MAX_NUM_CANDS) return MRG_MAX_NUM_CANDS;
|
||||
|
||||
int num_ref = state->global->ref->used_size;
|
||||
|
||||
if (state->global->slicetype == SLICE_B) {
|
||||
if (candidates < MRG_MAX_NUM_CANDS && state->global->slicetype == SLICE_B) {
|
||||
int j;
|
||||
int ref_negative = 0;
|
||||
int ref_positive = 0;
|
||||
|
|
|
@ -727,6 +727,9 @@ static void sao_search_best_mode(const encoder_state_t * const state, const pixe
|
|||
{
|
||||
sao_info_t edge_sao;
|
||||
sao_info_t band_sao;
|
||||
|
||||
init_sao_info(&edge_sao);
|
||||
init_sao_info(&band_sao);
|
||||
|
||||
//Avoid "random" uninitialized value
|
||||
edge_sao.band_position[0] = edge_sao.band_position[1] = 0;
|
||||
|
|
22
src/search.c
22
src/search.c
|
@ -419,14 +419,14 @@ static unsigned tz_search(const encoder_state_t * const state, unsigned depth,
|
|||
{
|
||||
|
||||
//TZ parameters
|
||||
int iSearchRange = 96; // search range for each stage
|
||||
int iRaster = 5; // search distance limit and downsampling factor for step 3
|
||||
unsigned step2_type = 0; // search patterns for steps 2 and 4
|
||||
unsigned step4_type = 0;
|
||||
bool bRasterRefinementEnable = true; // enable step 4 mode 1
|
||||
bool bStarRefinementEnable = false; // enable step 4 mode 2 (only one mode will be executed)
|
||||
const int iSearchRange = 96; // search range for each stage
|
||||
const int iRaster = 5; // search distance limit and downsampling factor for step 3
|
||||
const unsigned step2_type = 0; // search patterns for steps 2 and 4
|
||||
const unsigned step4_type = 0;
|
||||
const bool bRasterRefinementEnable = true; // enable step 4 mode 1
|
||||
const bool bStarRefinementEnable = false; // enable step 4 mode 2 (only one mode will be executed)
|
||||
|
||||
int block_width = CU_WIDTH_FROM_DEPTH(depth);
|
||||
const int block_width = CU_WIDTH_FROM_DEPTH(depth);
|
||||
|
||||
vector2d_t mv = { mv_in_out->x >> 2, mv_in_out->y >> 2 };
|
||||
|
||||
|
@ -1221,6 +1221,8 @@ static int search_cu_inter(const encoder_state_t * const state, int x, int y, in
|
|||
*/
|
||||
static void work_tree_copy_up(int x_px, int y_px, int depth, lcu_t work_tree[MAX_PU_DEPTH + 1])
|
||||
{
|
||||
assert(depth >= 0 && depth < MAX_PU_DEPTH);
|
||||
|
||||
// Copy non-reference CUs.
|
||||
{
|
||||
const int x_cu = SUB_SCU(x_px) >> MAX_DEPTH;
|
||||
|
@ -1274,6 +1276,8 @@ static void work_tree_copy_up(int x_px, int y_px, int depth, lcu_t work_tree[MAX
|
|||
*/
|
||||
static void work_tree_copy_down(int x_px, int y_px, int depth, lcu_t work_tree[MAX_PU_DEPTH + 1])
|
||||
{
|
||||
assert(depth >= 0 && depth < MAX_PU_DEPTH);
|
||||
|
||||
// TODO: clean up to remove the copy pasta
|
||||
const int width_px = LCU_WIDTH >> depth;
|
||||
|
||||
|
@ -1601,6 +1605,8 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
cu_info_t *const pred_cu,
|
||||
lcu_t *const lcu)
|
||||
{
|
||||
assert(depth >= 0 && depth <= MAX_PU_DEPTH);
|
||||
|
||||
const int width = LCU_WIDTH >> depth;
|
||||
const int width_c = width > TR_MIN_WIDTH ? width / 2 : width;
|
||||
|
||||
|
@ -1620,8 +1626,6 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
double split_cost = INT32_MAX;
|
||||
double nosplit_cost = INT32_MAX;
|
||||
|
||||
assert(width >= TR_MIN_WIDTH);
|
||||
|
||||
if (depth > 0) {
|
||||
tr_cu->tr_depth = depth;
|
||||
pred_cu->tr_depth = depth;
|
||||
|
|
Loading…
Reference in a new issue