diff --git a/app/xevd_app.c b/app/xevd_app.c index 55aab63..115a77d 100644 --- a/app/xevd_app.c +++ b/app/xevd_app.c @@ -66,14 +66,14 @@ static int read_bitstream(FILE * fp, int * pos, unsigned char * bs_buf) ret = xevd_info(nalu_len_buf, XEVD_NAL_UNIT_LENGTH_BYTE, 1, &info); if (XEVD_FAILED(ret)) { logv0("Cannot get bitstream information\n"); - return -1; + return XEVD_ERR; } bs_size = info.nalu_len; if(bs_size <= 0) { logv0("Invalid bitstream size![%d]\n", bs_size); - return -1; + return XEVD_ERR; } while(bs_size) @@ -82,7 +82,7 @@ static int read_bitstream(FILE * fp, int * pos, unsigned char * bs_buf) if (1 != fread(&b, 1, 1, fp)) { logv0("Cannot read bitstream!\n"); - return -1; + return XEVD_ERR; } bs_buf[read_size] = b; read_size++; @@ -94,13 +94,13 @@ static int read_bitstream(FILE * fp, int * pos, unsigned char * bs_buf) if(feof(fp)) {logv2("End of file\n");} else {logv0("Cannot read bitstream size!\n")}; - return -1; + return XEVD_ERR; } } else { logv0("Cannot seek bitstream!\n"); - return -1; + return XEVD_ERR; } return read_size; @@ -182,7 +182,7 @@ static int set_extra_config(XEVD id) if(XEVD_FAILED(ret)) { logv0("failed to set config for picture signature\n"); - return -1; + return XEVD_ERR; } } @@ -199,7 +199,7 @@ static int get_extra_config(XEVD id) if (XEVD_FAILED(ret)) { logv2("failed to get width\n"); - return -1; + return XEVD_ERR; } logv2("width = %d\n", width); @@ -208,7 +208,7 @@ static int get_extra_config(XEVD id) if (XEVD_FAILED(ret)) { logv2("failed to get height\n"); - return -1; + return XEVD_ERR; } logv2("height = %d\n", height); @@ -217,7 +217,7 @@ static int get_extra_config(XEVD id) if (XEVD_FAILED(ret)) { logv2("failed to get coded_width\n"); - return -1; + return XEVD_ERR; } logv2("coded_width = %d\n", coded_width); @@ -226,7 +226,7 @@ static int get_extra_config(XEVD id) if (XEVD_FAILED(ret)) { logv2("failed to get coded_height\n"); - return -1; + return XEVD_ERR; } logv2("coded_height = %d\n", coded_height); @@ -235,7 +235,7 @@ static int get_extra_config(XEVD id) if (XEVD_FAILED(ret)) { logv2("failed to get color_space\n"); - return -1; + return XEVD_ERR; } switch(color_space) { @@ -259,7 +259,7 @@ static int get_extra_config(XEVD id) if (XEVD_FAILED(ret)) { logv2("failed to get max_coding_delay\n"); - return -1; + return XEVD_ERR; } logv2("max_coding_delay = %d\n", max_coding_delay); return 0; @@ -300,7 +300,7 @@ static int write_y4m_header(char * fname, XEVD_IMGB * img) if (c_buf == NULL) { logv0("Color format is not suuported by y4m"); - return -1; + return XEVD_ERR; } /*setting fps to 30 by default as there is no fps related parameter */ @@ -312,9 +312,13 @@ static int write_y4m_header(char * fname, XEVD_IMGB * img) if (fp == NULL) { logv0("cannot open file = %s\n", fname); - return -1; + return XEVD_ERR; + } + if (buff_len != fwrite(buf, 1, buff_len, fp)) + { + fclose(fp); + return XEVD_ERR; } - if (buff_len != fwrite(buf, 1, buff_len, fp)) return -1; fclose(fp); return XEVD_OK; @@ -327,9 +331,13 @@ static int write_y4m_frame_header(char * fname) if (fp == NULL) { logv0("cannot open file = %s\n", fname); - return -1; + return XEVD_ERR; + } + if (6 != fwrite("FRAME\n", 1, 6, fp)) + { + fclose(fp); + return XEVD_ERR; } - if (6 != fwrite("FRAME\n", 1, 6, fp)) return -1; fclose(fp); return XEVD_OK; @@ -341,9 +349,9 @@ static int write_dec_img(XEVD id, char * fname, XEVD_IMGB * img, XEVD_IMGB * img imgb_cpy(imgb_t, img); if (flag_y4m) { - if(write_y4m_frame_header(op_fname_out)) return -1; + if(write_y4m_frame_header(op_fname_out)) return XEVD_ERR; } - if(imgb_write(op_fname_out, imgb_t)) return -1; + if(imgb_write(op_fname_out, imgb_t)) return XEVD_ERR; return XEVD_OK; } @@ -378,7 +386,7 @@ int main(int argc, const char **argv) { if(ret > 0) logv0("-%c argument should be set\n", ret); print_usage(); - return -1; + return XEVD_ERR; } logv1("eXtra-fast Essential Video Decoder\n"); @@ -388,7 +396,7 @@ int main(int argc, const char **argv) { logv0("ERROR: cannot open bitstream file = %s\n", op_fname_inp); print_usage(); - return -1; + return XEVD_ERR; } if(op_flag[OP_FLAG_FNAME_OUT]) @@ -398,9 +406,9 @@ int main(int argc, const char **argv) if(strlen(op_fname_out) < 5) /* x.yuv or x.y4m */ { logv0("ERROR: invalide output file name\n"); - return -1; + return XEVD_ERR; } - strcpy(fext, op_fname_out + strlen(op_fname_out) - 3); + strncpy(fext, op_fname_out + strlen(op_fname_out) - 3, 3); fext[0] = toupper(fext[0]); fext[1] = toupper(fext[1]); fext[2] = toupper(fext[2]); @@ -416,7 +424,7 @@ int main(int argc, const char **argv) else { logv0("ERROR: unknown output format\n"); - return -1; + return XEVD_ERR; } /* remove decoded file contents if exists */ FILE * fp; @@ -425,7 +433,7 @@ int main(int argc, const char **argv) { logv0("ERROR: cannot create a decoded file\n"); print_usage(); - return -1; + return XEVD_ERR; } fclose(fp); } @@ -434,7 +442,7 @@ int main(int argc, const char **argv) if(bs_buf == NULL) { logv0("ERROR: cannot allocate bit buffer, size=%d\n", MAX_BS_BUF); - return -1; + return XEVD_ERR; } cdsc.threads = (int)op_threads; @@ -442,12 +450,12 @@ int main(int argc, const char **argv) if(id == NULL) { logv0("ERROR: cannot create XEVD decoder\n"); - return -1; + return XEVD_ERR; } if(set_extra_config(id)) { logv0("ERROR: cannot set extra configurations\n"); - return -1; + return XEVD_ERR; } pic_cnt = 0; @@ -497,7 +505,7 @@ int main(int argc, const char **argv) if(XEVD_FAILED(ret)) { logv0("failed to decode bitstream\n"); - proc_ret = -1; + proc_ret = XEVD_ERR; goto END; } @@ -518,13 +526,13 @@ int main(int argc, const char **argv) if(ret == XEVD_ERR_UNEXPECTED) { logv2("bumping process completed\n"); - proc_ret = 0; + proc_ret = XEVD_OK; goto END; } else if(XEVD_FAILED(ret)) { logv0("failed to pull the decoded image\n"); - proc_ret = -1; + proc_ret = XEVD_ERR; goto END; } } @@ -565,7 +573,7 @@ int main(int argc, const char **argv) if(imgb_t == NULL) { logv0("failed to allocate temporay image buffer\n"); - proc_ret = -1; + proc_ret = XEVD_ERR; goto END; } //Copy the actual width and height of input image to temporary image. @@ -583,7 +591,7 @@ int main(int argc, const char **argv) { if(write_y4m_header(op_fname_out, imgb)) { - proc_ret = -1; + proc_ret = XEVD_ERR; goto END; } } diff --git a/app/xevd_app_util.h b/app/xevd_app_util.h index fb5b8d1..c381b4d 100644 --- a/app/xevd_app_util.h +++ b/app/xevd_app_util.h @@ -172,18 +172,18 @@ static int imgb_read(FILE * fp, XEVD_IMGB * img) size_l = f_w * f_h; if(fread(img->a[0], 1, size_l, fp) != (unsigned)size_l) { - return -1; + return XEVD_ERR; } size_cb = XEVDA_CRSHIFT(f_w, w_shift) * XEVDA_CRSHIFT(f_h, h_shift); if(chroma_format != XEVD_CF_YCBCR400) { if(fread(img->a[1], 1, size_cb, fp) != (unsigned)size_cb) { - return -1; + return XEVD_ERR; } if(fread(img->a[2], 1, size_cb, fp) != (unsigned)size_cb) { - return -1; + return XEVD_ERR; } } } @@ -193,7 +193,7 @@ static int imgb_read(FILE * fp, XEVD_IMGB * img) size_l = f_w * f_h * sizeof(short); if(fread(img->a[0], 1, size_l, fp) != (unsigned)size_l) { - return -1; + return XEVD_ERR; } size_cb = XEVDA_CRSHIFT(f_w, w_shift) * XEVDA_CRSHIFT(f_h, h_shift) * sizeof(short); @@ -201,21 +201,21 @@ static int imgb_read(FILE * fp, XEVD_IMGB * img) { if(fread(img->a[1], 1, size_cb, fp) != (unsigned)size_cb) { - return -1; + return XEVD_ERR; } if(fread(img->a[2], 1, size_cb, fp) != (unsigned)size_cb) { - return -1; + return XEVD_ERR; } } } else { logv0("not supported color space\n"); - return -1; + return XEVD_ERR; } - return 0; + return XEVD_OK; } static int imgb_write(char * fname, XEVD_IMGB * img) @@ -229,7 +229,7 @@ static int imgb_write(char * fname, XEVD_IMGB * img) if(fp == NULL) { logv0("cannot open file = %s\n", fname); - return -1; + return XEVD_ERR; } if ((img->cs & 0xff) != XEVD_CF_YCBCR400) { @@ -248,7 +248,8 @@ static int imgb_write(char * fname, XEVD_IMGB * img) else { logv0("cannot support the color space\n"); - return -1; + fclose(fp); + return XEVD_ERR; } for(i = 0; i < img->np; i++) { @@ -316,7 +317,7 @@ static int write_data(char * fname, unsigned char * data, int size) if(fp == NULL) { logv0("cannot open an writing file=%s\n", fname); - return -1; + return XEVD_ERR; } fwrite(data, 1, size, fp); fclose(fp); diff --git a/src_base/xevd_picman.c b/src_base/xevd_picman.c index 2998340..73efc5e 100644 --- a/src_base/xevd_picman.c +++ b/src_base/xevd_picman.c @@ -456,7 +456,6 @@ XEVD_PIC * xevd_picman_get_empty_pic(XEVD_PM * pm, int * err, int bit_depth) ERR: if(err) *err = ret; - if(pic) pm->pa.fn_free(&pm->pa, pic); return NULL; } diff --git a/src_base/xevd_util.c b/src_base/xevd_util.c index d972c3d..5c257b0 100644 --- a/src_base/xevd_util.c +++ b/src_base/xevd_util.c @@ -1238,9 +1238,8 @@ void xevd_eco_sbac_ctx_initialize(SBAC_CTX_MODEL *model, s16 *ctx_init_model, u1 s32 i, slope, offset; u16 mps, state; const int qp = XEVD_CLIP3(0, 51, slice_qp); - const int is_inter_slice = (slice_type == SLICE_B || slice_type == SLICE_P); - - ctx_init_model += (is_inter_slice * num_ctx); + + ctx_init_model += ((slice_type == SLICE_B) * num_ctx); for(i = 0; i < num_ctx; i++) { diff --git a/src_main/xevdm.c b/src_main/xevdm.c index 165b5f2..927f7c1 100644 --- a/src_main/xevdm.c +++ b/src_main/xevdm.c @@ -247,11 +247,13 @@ static int picture_init(XEVD_CTX * ctx) if (ctx->tc.task_num_in_tile == NULL) { ctx->tc.task_num_in_tile = (int*)xevd_malloc(sizeof(int) * ctx->tile_cnt); + xevd_assert_rv(ctx->tc.task_num_in_tile, XEVD_ERR_OUT_OF_MEMORY); } else { xevd_mfree(ctx->tc.task_num_in_tile); ctx->tc.task_num_in_tile = (int*)xevd_malloc(sizeof(int) * ctx->tile_cnt); + xevd_assert_rv(ctx->tc.task_num_in_tile, XEVD_ERR_OUT_OF_MEMORY); } if (ctx->tile == NULL) @@ -1644,7 +1646,7 @@ static int xevd_entropy_decode_tree(XEVD_CTX * ctx, XEVD_CORE * core, int x0, in , MODE_CONS mode_cons) { int ret; - s8 split_mode; + s8 split_mode = NO_SPLIT; int cuw, cuh; s8 suco_flag = 0; int bound; @@ -2634,6 +2636,7 @@ int xevdm_dec_slice(XEVD_CTX * ctx, XEVD_CORE * core) while (num_tiles_in_slice) { num_tiles_proc = num_tiles_in_slice > ctx->tc.tile_task_num ? ctx->tc.tile_task_num : num_tiles_in_slice; + core_mt = ctx->core_mt[num_tiles_proc - 1]; for (thread_idx = num_tiles_proc - 1; thread_idx >= 0; thread_idx--) { @@ -2713,26 +2716,32 @@ int xevdm_dec_slice(XEVD_CTX * ctx, XEVD_CORE * core) return ret; } -void xevd_malloc_1d(void** dst, int size) +int xevd_malloc_1d(void** dst, int size) { if(*dst == NULL) { *dst = xevd_malloc_fast(size); + xevd_assert_rv(*dst, XEVD_ERR_OUT_OF_MEMORY); + xevd_mset(*dst, 0, size); } + return XEVD_OK; } -void xevd_malloc_2d(s8*** dst, int size_1d, int size_2d, int type_size) +int xevd_malloc_2d(s8*** dst, int size_1d, int size_2d, int type_size) { int i; if(*dst == NULL) { *dst = xevd_malloc_fast(size_1d * sizeof(s8*)); - xevd_mset(*dst, 0, size_1d * sizeof(s8*)); + xevd_assert_rv(*dst, XEVD_ERR_OUT_OF_MEMORY); + xevd_mset(*dst, 0, size_1d * sizeof(s8*)); (*dst)[0] = xevd_malloc_fast(size_1d * size_2d * type_size); + xevd_assert_rv((*dst)[0], XEVD_ERR_OUT_OF_MEMORY); + xevd_mset((*dst)[0], 0, size_1d * size_2d * type_size); for(i = 1; i < size_1d; i++) @@ -2740,6 +2749,7 @@ void xevd_malloc_2d(s8*** dst, int size_1d, int size_2d, int type_size) (*dst)[i] = (*dst)[i - 1] + size_2d * type_size; } } + return XEVD_OK; } int xevd_create_cu_data(XEVD_CU_DATA *cu_data, int log2_cuw, int log2_cuh) @@ -2747,7 +2757,7 @@ int xevd_create_cu_data(XEVD_CU_DATA *cu_data, int log2_cuw, int log2_cuh) int i, j; int cuw_scu, cuh_scu; int size_8b, size_16b, size_32b, cu_cnt, pixel_cnt; - + int ret = XEVD_OK; cuw_scu = 1 << log2_cuw; cuh_scu = 1 << log2_cuh; @@ -2757,56 +2767,56 @@ int xevd_create_cu_data(XEVD_CU_DATA *cu_data, int log2_cuw, int log2_cuh) cu_cnt = cuw_scu * cuh_scu; pixel_cnt = cu_cnt << 4; - xevd_malloc_1d((void**)&cu_data->qp_y, size_8b); - xevd_malloc_1d((void**)&cu_data->qp_u, size_8b); - xevd_malloc_1d((void**)&cu_data->qp_v, size_8b); - xevd_malloc_1d((void**)&cu_data->pred_mode, size_8b); - xevd_malloc_1d((void**)&cu_data->pred_mode_chroma, size_8b); - - xevd_malloc_2d((s8***)&cu_data->mpm, 2, cu_cnt, sizeof(u8)); - xevd_malloc_2d((s8***)&cu_data->ipm, 2, cu_cnt, sizeof(u8)); - xevd_malloc_2d((s8***)&cu_data->mpm_ext, 8, cu_cnt, sizeof(u8)); - xevd_malloc_1d((void**)&cu_data->skip_flag, size_8b); - xevd_malloc_1d((void**)&cu_data->ibc_flag, size_8b); - xevd_malloc_1d((void**)&cu_data->dmvr_flag, size_8b); - xevd_malloc_2d((s8***)&cu_data->refi, cu_cnt, REFP_NUM, sizeof(u8)); - xevd_malloc_2d((s8***)&cu_data->mvp_idx, cu_cnt, REFP_NUM, sizeof(u8)); - xevd_malloc_1d((void**)&cu_data->mvr_idx, size_8b); - xevd_malloc_1d((void**)&cu_data->bi_idx, size_8b); - xevd_malloc_1d((void**)&cu_data->inter_dir, size_8b); - xevd_malloc_1d((void**)&cu_data->mmvd_idx, size_16b); - xevd_malloc_1d((void**)&cu_data->mmvd_flag, size_8b); - - xevd_malloc_1d((void**)& cu_data->ats_intra_cu, size_8b); - xevd_malloc_1d((void**)& cu_data->ats_mode_h, size_8b); - xevd_malloc_1d((void**)& cu_data->ats_mode_v, size_8b); - - xevd_malloc_1d((void**)&cu_data->ats_inter_info, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->qp_y, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->qp_u, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->qp_v, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->pred_mode, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->pred_mode_chroma, size_8b); + + ret = xevd_malloc_2d((s8***)&cu_data->mpm, 2, cu_cnt, sizeof(u8)); + ret = xevd_malloc_2d((s8***)&cu_data->ipm, 2, cu_cnt, sizeof(u8)); + ret = xevd_malloc_2d((s8***)&cu_data->mpm_ext, 8, cu_cnt, sizeof(u8)); + ret = xevd_malloc_1d((void**)&cu_data->skip_flag, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->ibc_flag, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->dmvr_flag, size_8b); + ret = xevd_malloc_2d((s8***)&cu_data->refi, cu_cnt, REFP_NUM, sizeof(u8)); + ret = xevd_malloc_2d((s8***)&cu_data->mvp_idx, cu_cnt, REFP_NUM, sizeof(u8)); + ret = xevd_malloc_1d((void**)&cu_data->mvr_idx, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->bi_idx, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->inter_dir, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->mmvd_idx, size_16b); + ret = xevd_malloc_1d((void**)&cu_data->mmvd_flag, size_8b); + + ret = xevd_malloc_1d((void**)& cu_data->ats_intra_cu, size_8b); + ret = xevd_malloc_1d((void**)& cu_data->ats_mode_h, size_8b); + ret = xevd_malloc_1d((void**)& cu_data->ats_mode_v, size_8b); + + ret = xevd_malloc_1d((void**)&cu_data->ats_inter_info, size_8b); for(i = 0; i < N_C; i++) { - xevd_malloc_1d((void**)&cu_data->nnz[i], size_32b); + ret = xevd_malloc_1d((void**)&cu_data->nnz[i], size_32b); } for (i = 0; i < N_C; i++) { for (j = 0; j < 4; j++) { - xevd_malloc_1d((void**)&cu_data->nnz_sub[i][j], size_32b); + ret = xevd_malloc_1d((void**)&cu_data->nnz_sub[i][j], size_32b); } } - xevd_malloc_1d((void**)&cu_data->map_scu, size_32b); - xevd_malloc_1d((void**)&cu_data->affine_flag, size_8b); - xevd_malloc_1d((void**)&cu_data->map_affine, size_32b); - xevd_malloc_1d((void**)&cu_data->map_cu_mode, size_32b); - xevd_malloc_1d((void**)&cu_data->depth, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->map_scu, size_32b); + ret = xevd_malloc_1d((void**)&cu_data->affine_flag, size_8b); + ret = xevd_malloc_1d((void**)&cu_data->map_affine, size_32b); + ret = xevd_malloc_1d((void**)&cu_data->map_cu_mode, size_32b); + ret = xevd_malloc_1d((void**)&cu_data->depth, size_8b); for(i = 0; i < N_C; i++) { - xevd_malloc_1d((void**)&cu_data->coef[i], (pixel_cnt >> (!!(i)* 2)) * sizeof(s16)); - xevd_malloc_1d((void**)&cu_data->reco[i], (pixel_cnt >> (!!(i)* 2)) * sizeof(pel)); + ret = xevd_malloc_1d((void**)&cu_data->coef[i], (pixel_cnt >> (!!(i)* 2)) * sizeof(s16)); + ret = xevd_malloc_1d((void**)&cu_data->reco[i], (pixel_cnt >> (!!(i)* 2)) * sizeof(pel)); } - return XEVD_OK; + return ret; } int xevdm_ready(XEVD_CTX *ctx) diff --git a/src_main/xevdm_alf.c b/src_main/xevdm_alf.c index 91c1150..33fbec6 100644 --- a/src_main/xevdm_alf.c +++ b/src_main/xevdm_alf.c @@ -490,10 +490,10 @@ void alf_init_filter_shape(void* _filter_shape, int size) } } -void alf_create(ADAPTIVE_LOOP_FILTER * alf, const int pic_width, const int pic_height, const int max_cu_width, const int max_cu_height, const int max_cu_depth, int chroma_format_idc, int bit_depth) +int alf_create(ADAPTIVE_LOOP_FILTER * alf, const int pic_width, const int pic_height, const int max_cu_width, const int max_cu_height, const int max_cu_depth, int chroma_format_idc, int bit_depth) { const int input_bit_depth[N_C] = { bit_depth, bit_depth }; - + int ret = XEVD_OK; xevd_mset(alf->alf_idx_in_scan_order, 0, sizeof(u8) * APS_MAX_NUM); alf->next_free_alf_idx_in_buf = 0; alf->first_idx_poc = INT_MAX; @@ -529,22 +529,30 @@ void alf_create(ADAPTIVE_LOOP_FILTER * alf, const int pic_width, const int pic_h alf->temp_buf2 = (pel*)malloc(((pic_width >> 1) + (7 * alf->num_ctu_in_widht))*((pic_height >> 1) + (7 * alf->num_ctu_in_height)) * sizeof(pel)); } alf->classifier_mt = (ALF_CLASSIFIER**)malloc(MAX_CU_SIZE * XEVD_MAX_TASK_CNT * sizeof(ALF_CLASSIFIER*)); + xevd_assert_rv(alf->classifier_mt, XEVD_ERR_OUT_OF_MEMORY); if (alf->classifier_mt) { for (int i = 0; i < MAX_CU_SIZE * XEVD_MAX_TASK_CNT; i++) { alf->classifier_mt[i] = (ALF_CLASSIFIER*)malloc(MAX_CU_SIZE * sizeof(ALF_CLASSIFIER)); + xevd_assert_rv(alf->classifier_mt, XEVD_ERR_OUT_OF_MEMORY); xevd_mset(alf->classifier_mt[i], 0, MAX_CU_SIZE * sizeof(ALF_CLASSIFIER)); } } // Classification alf->classifier = (ALF_CLASSIFIER**)malloc(pic_height * sizeof(ALF_CLASSIFIER*)); + xevd_assert_rv(alf->classifier, XEVD_ERR_OUT_OF_MEMORY); + for (int i = 0; i < pic_height; i++) { alf->classifier[i] = (ALF_CLASSIFIER*)malloc(pic_width * sizeof(ALF_CLASSIFIER)); + xevd_assert_rv(alf->classifier[i], XEVD_ERR_OUT_OF_MEMORY); + xevd_mset(alf->classifier[i], 0, pic_width * sizeof(ALF_CLASSIFIER)); } + + return XEVD_OK; } void alf_destroy(ADAPTIVE_LOOP_FILTER * alf) diff --git a/src_main/xevdm_alf.h b/src_main/xevdm_alf.h index 55acf88..1a5eccb 100644 --- a/src_main/xevdm_alf.h +++ b/src_main/xevdm_alf.h @@ -389,7 +389,7 @@ struct _ADAPTIVE_LOOP_FILTER ADAPTIVE_LOOP_FILTER* new_alf(int bit_depth); void delete_alf(ADAPTIVE_LOOP_FILTER* alf); -void alf_create(ADAPTIVE_LOOP_FILTER * alf, const int pic_width, const int pic_height, const int max_cu_width, const int max_cu_height, const int max_cu_depth, int chroma_format_idc, int bit_depth); +int alf_create(ADAPTIVE_LOOP_FILTER * alf, const int pic_width, const int pic_height, const int max_cu_width, const int max_cu_height, const int max_cu_depth, int chroma_format_idc, int bit_depth); void alf_destroy(ADAPTIVE_LOOP_FILTER * alf); void alf_init(ADAPTIVE_LOOP_FILTER * alf, int bit_depth); void alf_init_filter_shape(void * filter_shape, int size); diff --git a/src_main/xevdm_ipred.c b/src_main/xevdm_ipred.c index 3896146..c9b4b1c 100644 --- a/src_main/xevdm_ipred.c +++ b/src_main/xevdm_ipred.c @@ -127,7 +127,7 @@ void xevdm_get_nbr(int x, int y, int cuw, int cuh, pel *src, int s_src, u16 avai for (i = 0; i < (scuh + scuw); i++) { /*Check if right neighbours are available */ - int is_avail = (x_scu + scuw + i < w_scu) && (y_scu + i < h_scu); + int is_avail = (x_scu + scuw < w_scu) && (y_scu + i < h_scu); if (is_avail && MCU_GET_COD(map_scu[scup + scuw + i * w_scu]) && (!constrained_intra_pred || MCU_GET_IF(map_scu[scup + scuw + i * w_scu])) && (map_tidx[scup] == map_tidx[scup + scuw + i * w_scu])) { diff --git a/src_main/xevdm_itdq.c b/src_main/xevdm_itdq.c index d59a536..55ee394 100644 --- a/src_main/xevdm_itdq.c +++ b/src_main/xevdm_itdq.c @@ -99,7 +99,6 @@ void xevdm_init_multi_tbl() case 4: tm = xevd_tbl_tr32[0][0]; break; case 5: tm = xevd_tbl_tr64[0][0]; break; case 6: tm = xevd_tbl_tr128[0][0]; break; - case 7: exit(0); break; } for (k = 0; k < c; k++) @@ -140,7 +139,6 @@ void xevd_init_multi_inv_tbl() case 4: tm = xevd_tbl_inv_tr32[0][0]; break; case 5: tm = xevd_tbl_inv_tr64[0][0]; break; case 6: tm = xevd_tbl_inv_tr128[0][0]; break; - case 7: exit(0); break; } for (k = 0; k < c; k++) diff --git a/src_main/xevdm_picman.c b/src_main/xevdm_picman.c index b13b0eb..7be8b02 100644 --- a/src_main/xevdm_picman.c +++ b/src_main/xevdm_picman.c @@ -535,7 +535,6 @@ XEVD_PIC * xevdm_picman_get_empty_pic(XEVDM_PM * pm, int * err, int bitdepth) ERR: if(err) *err = ret; - if(pic) pm->pa.fn_free(&pm->pa, pic); return NULL; } diff --git a/src_main/xevdm_util.c b/src_main/xevdm_util.c index a1a2471..3f581af 100644 --- a/src_main/xevdm_util.c +++ b/src_main/xevdm_util.c @@ -3588,21 +3588,23 @@ void xevdm_get_tu_size(u8 ats_inter_info, int log2_cuw, int log2_cuh, int* log2_ u8 ats_inter_idx = get_ats_inter_idx(ats_inter_info); if (ats_inter_idx == 0) { - *log2_tuw = log2_cuw; - *log2_tuh = log2_cuh; + *log2_tuw = (log2_cuw > MAX_TR_LOG2) ? MAX_TR_LOG2 : log2_cuw; + *log2_tuh = (log2_cuh > MAX_TR_LOG2) ? MAX_TR_LOG2 : log2_cuh; return; } assert(ats_inter_idx <= 4); if (is_ats_inter_horizontal(ats_inter_idx)) { - *log2_tuw = log2_cuw; + *log2_tuw = (log2_cuw > MAX_TR_LOG2) ? MAX_TR_LOG2 : log2_cuw; *log2_tuh = is_ats_inter_quad_size(ats_inter_idx) ? log2_cuh - 2 : log2_cuh - 1; + *log2_tuh = (*log2_tuh > MAX_TR_LOG2) ? MAX_TR_LOG2 : *log2_tuh; } else { *log2_tuw = is_ats_inter_quad_size(ats_inter_idx) ? log2_cuw - 2 : log2_cuw - 1; - *log2_tuh = log2_cuh; + *log2_tuw = (*log2_tuw > MAX_TR_LOG2) ? MAX_TR_LOG2 : *log2_tuw; + *log2_tuh = (log2_cuh > MAX_TR_LOG2) ? MAX_TR_LOG2 : log2_cuh; } } @@ -3778,28 +3780,28 @@ void xevdm_get_mv_collocated(XEVD_REFP(*refp)[REFP_NUM], u32 poc, int scup, int } else { + dpoc_co[REFP_0] = 0; // collocated_mvp_source_list_idx = REFP_0; // specified above s8 refidx = map_refi_co[neb_addr_coll][collocated_mvp_source_list_idx]; - dpoc_co[REFP_0] = colPic.poc - colPic.list_poc[refidx]; + if(REFI_IS_VALID(refidx)) + dpoc_co[REFP_0] = colPic.poc - colPic.list_poc[refidx]; + + if (dpoc_co[REFP_0] != 0) { - if (dpoc_co[REFP_0] != 0 && REFI_IS_VALID(refidx)) - { - ver_refi[REFP_0] = 0; - ver_refi[REFP_1] = 0; - s16 *mvc = colPic.map_mv[neb_addr_coll][collocated_mvp_source_list_idx]; // collocated_mvp_source_list_idx == 0 for RA - int ratio_tmvp = ((dpoc[REFP_0]) << MVP_SCALING_PRECISION) / dpoc_co[REFP_0]; - scaling_mv(ratio_tmvp, mvc, mvp[REFP_0]); - - ratio_tmvp = ((dpoc[REFP_1]) << MVP_SCALING_PRECISION) / dpoc_co[REFP_0]; - scaling_mv(ratio_tmvp, mvc, mvp[REFP_1]); - } - else - { - mvp[REFP_0][MV_X] = 0; - mvp[REFP_0][MV_Y] = 0; - mvp[REFP_1][MV_X] = 0; - mvp[REFP_1][MV_Y] = 0; - } + ver_refi[REFP_0] = 0; + ver_refi[REFP_1] = 0; + s16 *mvc = colPic.map_mv[neb_addr_coll][collocated_mvp_source_list_idx]; // collocated_mvp_source_list_idx == 0 for RA + int ratio_tmvp = ((dpoc[REFP_0]) << MVP_SCALING_PRECISION) / dpoc_co[REFP_0]; + scaling_mv(ratio_tmvp, mvc, mvp[REFP_0]); + ratio_tmvp = ((dpoc[REFP_1]) << MVP_SCALING_PRECISION) / dpoc_co[REFP_0]; + scaling_mv(ratio_tmvp, mvc, mvp[REFP_1]); + } + else + { + mvp[REFP_0][MV_X] = 0; + mvp[REFP_0][MV_Y] = 0; + mvp[REFP_1][MV_X] = 0; + mvp[REFP_1][MV_Y] = 0; } }