ci dx_auth认证

最近看到了一个比较好的ci认证类,特此分享

 

 

下面是 DX Auth 库中的配置,你可以看一下代码中的注释。

/*
| -------------------------------------------------------------------
| DX Auth Config
| -------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| 网站细节
|--------------------------------------------------------------------------
|
| 这些细节用于 DX Auth 库发送的E-mail里。
|
*/
$config['DX_website_name'] = '你的网站名';
$config['DX_webmaster_email'] =
'webmaster@yourhost.com';
/*
|--------------------------------------------------------------------------
| 数据库表
|--------------------------------------------------------------------------
|
| 设定 DX Auth 使用的表
|
| 'DX_table_prefix' 允许你指定其余表用到的表前缀
|
| 例如 'DX_table_prefix' 设定为 'DX_','DX_users_table' 设置为 'user',
| 将会使 DX Auth 使用 'DX_users' 作为用户表.
|
*/
$config['DX_table_prefix'] = '';
$config['DX_users_table'] = 'users';
$config['DX_user_profile_table'] = 'user_profile';
$config['DX_user_temp_table'] = 'user_temp';
$config['DX_user_autologin'] = 'user_autologin';
$config['DX_roles_table'] = 'roles';
$config['DX_permissions_table'] = 'permissions';
$config['DX_login_attempts_table'] = 'login_attempts';
/*
|--------------------------------------------------------------------------
| 密码混淆 (salt)
|--------------------------------------------------------------------------
|
| You can add major salt to be hashed with password.
| For example, you can get salt from here:
https://www.grc.com/passwords.htm
|
| 注意:
|
| 记住如果你在有用户注册之后修改此值,之前注册的用户将无法再登录
|
*/
$config['DX_salt'] = '';
/*
|--------------------------------------------------------------------------
| 注册相关设置
|--------------------------------------------------------------------------
|
| 'DX_email_activation' = 要求用户注册后激活他们的帐号
| 'DX_email_activation_expire' = 激活限制时间,超过此时间扔未激活的用户将被从数据库中删除。默认是48小时 (60*60*24*2)。
| 'DX_email_account_details' = 注册后发送帐号详情的邮件。只在 'DX_email_activation' 为 FALSE 时有效。
|
*/

$config['DX_email_activation'] = TRUE;
$config['DX_email_activation_expire'] = 60*60*24*2;
$config['DX_email_account_details'] = TRUE;
/*
|--------------------------------------------------------------------------
| 登录设置
|--------------------------------------------------------------------------
|
| 'DX_login_using_username' = 设定用户是否可以在用户名表单域使用用户名登录。
| 'DX_login_using_email' = 设定用户是否可以在用户名表单域使用E-mail登录。
|
| 以上两项你必须至少设置一项为True。
|
| 'DX_login_record_ip' = 设定当用户登录时是否将其IP保存到数据库。
| 'DX_login_record_time' = 设定当用户登录时是否记录其登录时间。
|
*/
$config['DX_login_using_username'] = TRUE;
$config['DX_login_using_email'] = TRUE;
$config['DX_login_record_ip'] = TRUE;
$config['DX_login_record_time'] = TRUE;
/*
|--------------------------------------------------------------------------
| 自动登录设置
|--------------------------------------------------------------------------
|
| 'DX_autologin_cookie_name' = 设置自动登录所使用的Cookie名字。
| 'DX_autologin_cookie_life' = 设置自动登录所使用的cookie有效时间。默认为2个月(60*60*24*31*2)。
|
*/
$config['DX_autologin_cookie_name'] = 'autologin';
$config['DX_autologin_cookie_life'] = 60*60*24*31*2;
/*
|--------------------------------------------------------------------------
| 登录尝试
|--------------------------------------------------------------------------
|
| 'DX_count_login_attempts' = 设定当用户登录失败是 DX Auth 是否统计登录失败次数。
| 'DX_max_login_attempts' = 设定函数 is_login_attempt_exceeded() 返回 TRUE 之前的最大尝试次数。
|
*/
$config['DX_count_login_attempts'] = TRUE;
$config['DX_max_login_attempts'] = 1;
/*
|--------------------------------------------------------------------------
| 忘记密码相关设置
|--------------------------------------------------------------------------
|
| 'DX_forgot_password_expire' = 忘记密码密钥超时时间,默认为 15 分钟(900 seconds)。
|
*/
$config['DX_forgot_password_expire'] = 900;
/*
|--------------------------------------------------------------------------
| 验证码
|--------------------------------------------------------------------------
|
| 你可以在此设定由 DX Auth 库生成的验证码。
| 'DX_captcha_directory' = 创建验证码的目录名称。
| 'DX_captcha_fonts_path' = 此目录中的字体将被用于验证码的创建。
| 'DX_captcha_font_size' = 文本写入验证码图片时的字体大小。使用随机大小请留空。
| 'DX_captcha_grid' = 在验证码图片中显示网格
| 'DX_captcha_expire' = 验证码超时时间,默认为3分钟(180 seconds)。
| 'DX_captcha_case_sensitive' = 设定验证码是否区分大小写。
|
*/
$config['DX_captcha_directory'] = 'captcha';
$config['DX_captcha_fonts_path'] = $config['DX_captcha_path'].'fonts';
$config['DX_captcha_width'] = 320;
$config['DX_captcha_height'] = 95;
$config['DX_captcha_font_size'] = '';
$config['DX_captcha_grid'] = TRUE;
$config['DX_captcha_expire'] = 180;
$config['DX_captcha_case_sensitive'] = TRUE;
/*
|--------------------------------------------------------------------------
| reCAPTCHA //此段略
|--------------------------------------------------------------------------
|
| If you are planning to use reCAPTCHA function, you have to set reCAPTCHA key here
| You can get the key by registering at
http://recaptcha.net
|
*/
$config['DX_recaptcha_public_key'] = '';
$config['DX_recaptcha_private_key'] = '';

/*
|--------------------------------------------------------------------------
| URI
|--------------------------------------------------------------------------
|
| 设定在 DX Auth 库中用于重定向的 URI
| 'DX_deny_uri' = 禁止访问 URI.
| 'DX_login_uri' = 登录表单 URI.
| 'DX_activate_uri' = 激活用户 URI.
| 'DX_reset_password_uri' = 重置密码 URI.
|
| 去掉'DX_'前缀,这些值可以由 DX Auth 库读取。
| 例如你可以在控制器中通过使用 $this->dx_auth->deny_uri 访问 'DX_deny_uri'。
|
*/
$config['DX_deny_uri'] = '/auth/deny/';
$config['DX_login_uri'] = '/auth/login/';
$config['DX_banned_uri'] = '/auth/banned/';
$config['DX_activate_uri'] = '/auth/activate/';
$config['DX_reset_password_uri'] = '/auth/reset_password/';

/*
|--------------------------------------------------------------------------
| 辅助函数配置
|--------------------------------------------------------------------------
|
| 下面的配置实际上在 DX_Auth 库中并没有用到。
| 它们只是帮助你在控制器里更容易地编写代码。
| 如果你不需要它你可以留空,或干脆删掉它。
|
| 然而它们可以通过去掉'DX_'前缀在 DX Auth 库中访问。
| 例如你可以在控制器中通过使用 $this->dx_auth->register_uri 访问 'DX_register_uri'。
|
*/
// 注册
$config['DX_allow_registration'] = TRUE;
$config['DX_captcha_registration'] = TRUE;
// 登录
$config['DX_captcha_login'] = FALSE;
// URI 路径
$config['DX_logout_uri'] = '/auth/logout/';
$config['DX_register_uri'] = '/auth/register/';
$config['DX_forgot_password_uri'] = '/auth/forgot_password/';
$config['DX_change_password_uri'] = '/auth/change_password/';
$config['DX_cancel_account_uri'] = '/auth/cancel_account/';
// 表单视图
$config['DX_login_view'] = 'auth/login_form';
$config['DX_register_view'] = 'auth/register_form';
$config['DX_forgot_password_view'] = 'auth/forgot_password_form';
$config['DX_change_password_view'] = 'auth/change_password_form';
$config['DX_cancel_account_view'] = 'auth/cancel_account_form';
// 页面视图
$config['DX_deny_view'] = 'auth/general_message';
$config['DX_banned_view'] = 'auth/general_message';
$config['DX_logged_in_view'] = 'auth/general_message';
$config['DX_logout_view'] = 'auth/general_message';
$config['DX_register_success_view'] = 'auth/general_message';
$config['DX_activate_success_view'] = 'auth/general_message';
$config['DX_forgot_password_success_view'] = 'auth/general_message';
$config['DX_reset_password_success_view'] = 'auth/general_message';
$config['DX_change_password_success_view'] = 'auth/general_message';

$config['DX_register_disabled_view'] = 'auth/general_message';
$config['DX_activate_failed_view'] = 'auth/general_message';
$config['DX_reset_password_failed_view'] = 'auth/general_message';

int dec_cnk(DEC_CTX * ctx, COM_BITB * bitb, DEC_STAT * stat) { COM_BSR *bs; COM_PIC_HEADER *pic_header; COM_SQH * sqh; #if SVAC_SECURITY_PARAM_SET COM_SEC_PARA_SET* sec_para_set; #endif #if SVAC_AUTHENTICATION COM_AUTH_DATA* auth_data; #endif #if HLS_OPT_PPS COM_PIC_PARA_SET * pps; #endif COM_SH_EXT *shext; COM_CNKH *cnkh; int ret = COM_OK; if (stat) { com_mset(stat, 0, sizeof(DEC_STAT)); } bs = &ctx->bs; sqh = &ctx->info.sqh; #if HLS_OPT_PPS pps = &ctx->info.pps[ctx->info.pps_count]; #endif pic_header = &ctx->info.pic_header; shext = &ctx->info.shext; cnkh = &ctx->info.cnkh; #if SVAC_SECURITY_PARAM_SET sec_para_set = &ctx->info.sec_para_set; #endif #if SVAC_AUTHENTICATION auth_data = &ctx->info.auth_data; #endif /* set error status */ ctx->bs_err = (u8)bitb->err; #if TRACE_RDO_EXCLUDE_I if (pic_header->slice_type != SLICE_I) { #endif COM_TRACE_SET(1); #if TRACE_RDO_EXCLUDE_I } else { COM_TRACE_SET(0); } #endif /* bitstream reader initialization */ com_bsr_init(bs, bitb->addr, bitb->ssize, NULL); SET_SBAC_DEC(bs, &ctx->sbac_dec); #if SVAC_NAL if (bs->cur[3] == SVAC_SPS) #else if (bs->cur[3] == 0xB0) #endif { #if LIB_PIC_MIXBIN int need_update = COM_CT_CRR_SLICE == cnkh->ctype || COM_CT_CRR_SLICE_IMCOPLETE == cnkh->ctype #if SVAC_SECURITY_PARAM_SET || cnkh->ctype == COM_CT_SEC_PARA_SET #endif ; #endif #if HLS_OPT_PPS ctx->info.pps_count = 0; memset(ctx->info.pps, 0, sizeof(ctx->info.pps)); #endif cnkh->ctype = COM_CT_SQH; ret = dec_eco_sqh(bs, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); #if LIBVC_ON ctx->dpm.libvc_data->is_libpic_processing = sqh->library_stream_flag; ctx->dpm.libvc_data->library_picture_enable_flag = sqh->library_picture_enable_flag; #if LIBPIC_DISPLAY ctx->dpm.libvc_data->libpic_mode_index = sqh->library_picture_mode_index; #endif #endif #if EXTENSION_USER_DATA extension_and_user_data(ctx, bs, 0, sqh, pic_header); #endif #if LIB_PIC_MIXBIN if (sqh->library_stream_flag) { if (!ctx->libpic_init_flag) { ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); #if MULTI_LAYER_FRAMEWORK g_DOIPrev[ctx->layer_id] = g_CountDOICyCleTime[ctx->layer_id] = 0; #else g_DOIPrev = g_CountDOICyCleTime = 0; #endif ctx->libpic_init_flag = 1; ctx->init_flag = 1; } } else #endif if( !ctx->init_flag ) { ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); #if MULTI_LAYER_FRAMEWORK g_DOIPrev[ctx->layer_id] = g_CountDOICyCleTime[ctx->layer_id] = 0; #else g_DOIPrev = g_CountDOICyCleTime = 0; #endif ctx->init_flag = 1; } #if LIB_PIC_MIXBIN if (sqh->library_stream_flag && sqh->library_picture_mixbin_flag) { memcpy(&ctx->info.libpic_sqh, sqh, sizeof(COM_SQH)); ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); } else { memcpy(&ctx->info.normal_sqh, sqh, sizeof(COM_SQH)); if (need_update) { ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); } } #endif } #if !SVAC_NAL else if( bs->cur[3] == 0xB1 ) { ctx->init_flag = 0; cnkh->ctype = COM_CT_SEQ_END; } #endif #if HLS_OPT_PPS else if (bs->cur[3] == SVAC_PPS) { cnkh->ctype = COM_CT_PPS; ret = dec_eco_pps(bs, sqh, pps); ctx->info.pps_count++; assert(ctx->info.pps_count <= MAX_PPS_NUM); com_assert_rv(COM_SUCCEEDED(ret), ret); #if LIB_PIC_MIXBIN if (sqh->library_stream_flag) ctx->info.libpic_pps_idx = ctx->info.pps_count - 1; else ctx->info.normal_pps_idx = ctx->info.pps_count - 1; #endif } #endif #if SVAC_NAL #if HLS_OPT_PPS else if (bs->cur[3] == SVAC_PH) #else else if (bs->cur[3] == SVAC_PPS) #endif #else else if (bs->cur[3] == 0xB3 || bs->cur[3] == 0xB6) #endif { #if MULTI_LAYER_FRAMEWORK if (ctx->layer_id) { if (!ctx->init_flag) { ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); g_DOIPrev[ctx->layer_id] = g_CountDOICyCleTime[ctx->layer_id] = 0; ctx->init_flag = 1; if (ctx->layer_id && !sqh->sps_independent_layer_flag[ctx->layer_id]) { COM_PM* pm = &(ctx->dpm); int size; pm->pic_tmp[0] = com_pic_alloc(&pm->pa, &ret); pm->pic_tmp[1] = com_pic_alloc(&pm->pa, &ret); size = sizeof(s8) * ctx->info.f_scu * REFP_NUM; memset(pm->pic_tmp[0]->map_refi, -1, size); size = sizeof(s16) * ctx->info.f_scu * REFP_NUM * MV_D; memset(pm->pic_tmp[0]->map_mv, 0, size); #if CU_LEVEL_PRIVACY size = sizeof(u8) * ctx->info.f_scu; memset(pm->pic_tmp[0]->map_privacy, 0, size); #endif } } } #endif #if LIB_PIC_MIXBIN if (COM_CT_CRR_SLICE == cnkh->ctype || COM_CT_CRR_SLICE_IMCOPLETE == cnkh->ctype) { assert(sqh->library_picture_mixbin_flag == 1); memcpy(sqh, &ctx->info.normal_sqh, sizeof(COM_SQH)); ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); #if HLS_OPT_PPS pps = &ctx->info.pps[ctx->info.normal_pps_idx]; #endif ctx->dpm.libvc_data->is_libpic_processing = sqh->library_stream_flag; ctx->dpm.libvc_data->library_picture_enable_flag = sqh->library_picture_enable_flag; } #endif cnkh->ctype = COM_CT_PICTURE; /* decode slice header */ pic_header->low_delay = sqh->low_delay; int need_minus_256 = 0; #if HLS_OPT_PPS ret = dec_eco_pic_header(bs, ctx, &need_minus_256); #if MULTI_LAYER_FRAMEWORK assert(ctx->layer_id == pic_header->layer_id); if (ctx->layer_id && !sqh->sps_independent_layer_flag[ctx->layer_id] ) { DEC_CTX* ctx_b = (DEC_CTX*)ctx->ctx_b; upsample_base_pic(&ctx->dpm, ctx_b->pic, &ctx_b->info, &ctx->info, ctx_b->layer_id, ctx->layer_id); add_pic(&ctx_b->dpm, &ctx->dpm, ctx_b->pic, ctx_b->layer_id, &ctx_b->info, &ctx->info, ctx_b->info.pic_header.decode_order_index, ctx_b->ptr, ctx->refp, ctx->info.sqh.ref_layer_id[ctx->layer_id], ctx_b->info.poc); } #endif #else ret = dec_eco_pic_header(bs, pic_header, sqh, &need_minus_256); #endif if (need_minus_256) { com_picman_dpbpic_doi_minus_cycle_length( &ctx->dpm ); } #if HLS_OPT_PPS ctx->wq[0] = ctx->info.pps[pic_header->pic_pps_id].wq_4x4_matrix; ctx->wq[1] = ctx->info.pps[pic_header->pic_pps_id].wq_8x8_matrix; #else ctx->wq[0] = pic_header->wq_4x4_matrix; ctx->wq[1] = pic_header->wq_8x8_matrix; #endif if (!sqh->library_stream_flag) { com_picman_check_repeat_doi(&ctx->dpm, pic_header); } #if LIB_PIC_MIXBIN if (sqh->library_stream_flag && sqh->library_picture_mixbin_flag) { memcpy(&ctx->info.libpic_pic_header, pic_header, sizeof(COM_PIC_HEADER)); memcpy(ctx->libpic_pic_esao_params, ctx->info.pic_header.pic_esao_params, N_C * sizeof(ESAO_BLK_PARAM)); memcpy(ctx->libpic_pic_ccsao_params, ctx->info.pic_header.pic_ccsao_params, (N_C - 1) * sizeof(CCSAO_BLK_PARAM)); for (int comp_idx = 0; comp_idx < N_C; comp_idx++) { #if ALF_SHAPE int num_coef = (ctx->info.sqh.adaptive_leveling_filter_enhance_flag) ? ALF_MAX_NUM_COEF_SHAPE2 : ALF_MAX_NUM_COEF; #endif copy_alf_param(ctx->dec_alf->libpic_alf_picture_param[comp_idx], ctx->dec_alf->alf_picture_param[comp_idx] #if ALF_SHAPE , num_coef #if ALF_SHIFT + (int)ctx->info.sqh.adaptive_leveling_filter_enhance_flag #endif #endif ); } } #endif #if LIBPIC_DISPLAY ctx->dpm.libvc_data->libpic_index = pic_header->library_picture_index; #endif #if HIGH_LEVEL_PRIVACY memset(ctx->ctx_privacy_data.region_max_num, 0, sizeof(int) * 10); #endif #if EXTENSION_USER_DATA && WRITE_MD5_IN_USER_DATA extension_and_user_data(ctx, bs, 1, sqh, pic_header); #endif com_constrcut_ref_list_doi(pic_header); //add by Yuqun Fan, init rpl list at ph instead of sh #if HLS_RPL #if LIBVC_ON if (!sqh->library_stream_flag) #endif { ret = com_picman_refpic_marking_decoder(&ctx->dpm, pic_header); com_assert_rv(ret == COM_OK, ret); } com_cleanup_useless_pic_buffer_in_pm(&ctx->dpm); /* reference picture lists construction */ ret = com_picman_refp_rpl_based_init_decoder(&ctx->dpm, pic_header, ctx->refp); #if AWP if (ctx->info.pic_header.slice_type == SLICE_P || ctx->info.pic_header.slice_type == SLICE_B) { for (int i = 0; i < ctx->dpm.num_refp[REFP_0]; i++) { ctx->info.pic_header.ph_poc[REFP_0][i] = ctx->refp[i][REFP_0].ptr; } } if (ctx->info.pic_header.slice_type == SLICE_B) { for (int i = 0; i < ctx->dpm.num_refp[REFP_1]; i++) { ctx->info.pic_header.ph_poc[REFP_1][i] = ctx->refp[i][REFP_1].ptr; } } #endif #endif com_assert_rv(COM_SUCCEEDED(ret), ret); } #if SVAC_NAL else if ((bs->cur[3] == SVAC_IDR || bs->cur[3] == SVAC_NON_RAP || bs->cur[3] == SVAC_RAP_I #if LIB_PIC_MIXBIN || bs->cur[3] == SVAC_CRR_L || bs->cur[3] == SVAC_CRR_RL #if DISPLAY_L_NAL_TYPE || bs->cur[3] == SVAC_CRR_DP #endif #if LIB_PIC_ERR_TOL || bs->cur[3] == SVAC_CRR_DL #endif #endif ) && bs->cur[4] <= 0x8E) #else else if (bs->cur[3] >= 0x00 && bs->cur[3] <= 0x8E) #endif { #if LIB_PIC_MIXBIN #if DISPLAY_L_NAL_TYPE if (!sqh->library_stream_flag && (bs->cur[3] == SVAC_CRR_L || bs->cur[3] == SVAC_CRR_DP #if LIB_PIC_ERR_TOL || bs->cur[3] == SVAC_CRR_DL #endif )) #else if (!sqh->library_stream_flag && bs->cur[3] == SVAC_CRR_L) #endif { assert(sqh->library_picture_mixbin_flag == 1); memcpy(sqh, &ctx->info.libpic_sqh, sizeof(COM_SQH)); ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); #if HLS_OPT_PPS pps = &ctx->info.pps[ctx->info.libpic_pps_idx]; #endif ctx->dpm.libvc_data->is_libpic_processing = sqh->library_stream_flag; ctx->dpm.libvc_data->library_picture_enable_flag = sqh->library_picture_enable_flag; memcpy(pic_header, &ctx->info.libpic_pic_header, sizeof(COM_PIC_HEADER)); memcpy(pic_header->pic_esao_params, ctx->libpic_pic_esao_params, N_C * sizeof(ESAO_BLK_PARAM)); memcpy(pic_header->pic_ccsao_params, ctx->libpic_pic_ccsao_params, (N_C - 1) * sizeof(CCSAO_BLK_PARAM)); memcpy(ctx->pic_alf_on, ctx->libpic_pic_alf_on, N_C * sizeof(int)); for (int comp_idx = 0; comp_idx < N_C; comp_idx++) { #if ALF_SHAPE int num_coef = (ctx->info.sqh.adaptive_leveling_filter_enhance_flag) ? ALF_MAX_NUM_COEF_SHAPE2 : ALF_MAX_NUM_COEF; #endif copy_alf_param(ctx->dec_alf->alf_picture_param[comp_idx], ctx->dec_alf->libpic_alf_picture_param[comp_idx] #if ALF_SHAPE , num_coef #if ALF_SHIFT + (int)ctx->info.sqh.adaptive_leveling_filter_enhance_flag #endif #endif ); memcpy(ctx->info.pic_header.pic_esao_params[comp_idx].lcu_flag, ctx->libpic_esao_lcu_flag[comp_idx], ctx->info.f_lcu * sizeof(int)); if (comp_idx) memcpy(ctx->info.pic_header.pic_ccsao_params[comp_idx - 1].lcu_flag, ctx->libpic_ccsao_lcu_flag[comp_idx - 1], ctx->info.f_lcu * sizeof(int)); } for (int lcu_idx = 0; lcu_idx < ctx->info.f_lcu; lcu_idx++) { copy_sao_param_for_blk(ctx->sao_blk_params[lcu_idx], ctx->libpic_sao_blk_params[lcu_idx]); copy_sao_param_for_blk(ctx->rec_sao_blk_params[lcu_idx], ctx->libpic_rec_sao_blk_params[lcu_idx]); memcpy(ctx->dec_alf->alf_lcu_enabled[lcu_idx], ctx->dec_alf->libpic_alf_lcu_enabled[lcu_idx], N_C * sizeof(int)); } memcpy(ctx->map.map_pb_tb_part, ctx->map.libpic_map_pb_tb_part, ctx->info.f_scu * sizeof(u32)); memcpy(ctx->map.map_patch_idx, ctx->map.libpic_map_patch_idx, ctx->info.f_scu * sizeof(s8)); memcpy(ctx->map.map_split, ctx->map.libpic_map_split, ctx->info.f_lcu * sizeof(s8)* MAX_CU_DEPTH* NUM_BLOCK_SHAPE* MAX_CU_CNT_IN_LCU); mCabac_ws = MCABAC_SHIFT_I; mCabac_offset = (1 << (mCabac_ws - 1)); counter_thr1 = 0; counter_thr2 = COUNTER_THR_I; #if HLS_OPT_PPS ctx->wq[0] = ctx->info.pps[pic_header->pic_pps_id].wq_4x4_matrix; ctx->wq[1] = ctx->info.pps[pic_header->pic_pps_id].wq_8x8_matrix; #else ctx->wq[0] = pic_header->wq_4x4_matrix; ctx->wq[1] = pic_header->wq_8x8_matrix; #endif } #if DISPLAY_L_NAL_TYPE if (sqh->library_stream_flag && (bs->cur[3] != SVAC_CRR_L && bs->cur[3] != SVAC_CRR_DP #if LIB_PIC_ERR_TOL && bs->cur[3] != SVAC_CRR_DL #endif )) #else if (sqh->library_stream_flag && bs->cur[3] != SVAC_CRR_L) #endif { assert(sqh->library_picture_mixbin_flag == 1); memcpy(sqh, &ctx->info.normal_sqh, sizeof(COM_SQH)); ret = sequence_init(ctx, sqh); com_assert_rv(COM_SUCCEEDED(ret), ret); #if HLS_OPT_PPS pps = &ctx->info.pps[ctx->info.normal_pps_idx ]; #endif ctx->dpm.libvc_data->is_libpic_processing = sqh->library_stream_flag; ctx->dpm.libvc_data->library_picture_enable_flag = sqh->library_picture_enable_flag; } #if LIBPIC_DISPLAY int is_patch_l = sqh->library_stream_flag && sqh->library_picture_mixbin_flag && ctx->info.sqh.library_picture_mode_index != 1; #else int is_patch_l = sqh->library_stream_flag && sqh->library_picture_mixbin_flag; #endif #endif cnkh->ctype = COM_CT_SLICE; #if SVAC_NAL if (bs->cur[3] == SVAC_IDR) picman_reset_dpb(&ctx->dpm); #endif #if CU_LEVEL_PRIVACY COM_BSR *bs_privacy = &ctx->bs_privacy; com_bsr_init(bs_privacy, bitb->addr2, bitb->ssize2, NULL); SET_SBAC_DEC(bs_privacy, &ctx->sbac_dec_privacy); if (ctx->user_permission && ctx->info.pic_header.ph_privacy_on) { while (com_bsr_next(bs_privacy, 24) != 0x1) { ret = com_bsr_read(bs_privacy, 8); }; unsigned int nalu_type = 0, temporal_id = 0, layer_id = 0; dec_eco_nalu_header(bs_privacy, &nalu_type, &temporal_id, &layer_id); assert(nalu_type == SVAC_PRIVACY); #if TSVC_OPT assert(temporal_id == ctx->info.pic_header.temporal_id); #endif #if MULTI_LAYER_FRAMEWORK assert(layer_id == ctx->info.pic_header.layer_id); #endif } #endif #if HLS_OPT_PPS ret = dec_eco_patch_header(bs, sqh, &ctx->info.pps[pic_header->pic_pps_id], pic_header, shext, ctx->patch); #else ret = dec_eco_patch_header(bs, sqh, pic_header, shext, ctx->patch); #endif #if LIB_PIC_MIXBIN if (is_patch_l && ctx->patch->idx + 1 < ctx->patch->rows * ctx->patch->columns) cnkh->ctype = COM_CT_CRR_SLICE_IMCOPLETE; #if LIBPIC_DISPLAY else if (is_patch_l || (sqh->library_stream_flag && ctx->info.sqh.library_picture_mode_index == 1)) #else else if (is_patch_l) #endif cnkh->ctype = COM_CT_CRR_SLICE; #endif /* initialize slice */ ret = slice_init(ctx, ctx->core, pic_header); com_assert_rv(COM_SUCCEEDED(ret), ret); #if LIB_PIC_MIXBIN if (is_patch_l && ctx->patch->idx != 0) { ctx->pic = ctx->libpic_pic; } else { #endif /* get available frame buffer for decoded image */ ctx->pic = com_picman_get_empty_pic(&ctx->dpm, &ret); com_assert_rv(ctx->pic, ret); #if LIB_PIC_MIXBIN if (is_patch_l && ctx->patch->idx == 0) ctx->libpic_pic = ctx->pic; } #endif /* get available frame buffer for decoded image */ ctx->map.map_refi = ctx->pic->map_refi; ctx->map.map_mv = ctx->pic->map_mv; #if CU_LEVEL_PRIVACY ctx->map.map_privacy = ctx->pic->map_privacy; #endif #if CU_LEVEL_PRIVACY com_mset_x64a(ctx->map.map_privacy_pic_filter[0], 0, sizeof(COM_FILTER_SKIP)* ctx->info.pic_width* ctx->info.pic_height); com_mset_x64a(ctx->map.map_privacy_pic_filter[1], 0, sizeof(COM_FILTER_SKIP)* ctx->info.pic_width* ctx->info.pic_height); #endif /* decode slice layer */ #if HLS_OPT_PPS ret = dec_pic(ctx, ctx->core, sqh, &ctx->info.pps[pic_header->pic_pps_id], pic_header, shext); #else ret = dec_pic(ctx, ctx->core, sqh, pic_header, shext); #endif com_assert_rv(COM_SUCCEEDED(ret), ret); #if LIB_PIC_MIXBIN if (!is_patch_l || (is_patch_l && ctx->patch->idx + 1 == ctx->patch->rows * ctx->patch->columns)) { #endif /* deblocking filter */ #if HLS_OPT_PPS if (ctx->info.pps[ctx->info.pic_header.pic_pps_id].loop_filter_disable_flag == 0) #else if (ctx->info.pic_header.loop_filter_disable_flag == 0) #endif { ret = dec_deblock_avs2(ctx); com_assert_rv(COM_SUCCEEDED(ret), ret); } #if CCSAO if (ctx->info.pic_header.pic_ccsao_on[U_C-1] || ctx->info.pic_header.pic_ccsao_on[V_C-1]) { #if CCSAO_ENHANCEMENT copy_frame_for_ccsao(ctx->pic_ccsao[0], ctx->pic, Y_C); copy_frame_for_ccsao(ctx->pic_ccsao[0], ctx->pic, U_C); copy_frame_for_ccsao(ctx->pic_ccsao[0], ctx->pic, V_C); #else copy_frame_for_ccsao(ctx->pic_ccsao, ctx->pic, Y_C); #endif } #endif /* sao filter */ if (ctx->info.sqh.sample_adaptive_offset_enable_flag) { ret = dec_sao_avs2(ctx); com_assert_rv(ret == COM_OK, ret); } /* esao filter */ #if ESAO if (ctx->info.sqh.esao_enable_flag) { ret = dec_esao(ctx); com_assert_rv(ret == COM_OK, ret); } #endif #if CCSAO /* ccsao filter */ if (ctx->info.sqh.ccsao_enable_flag) { ret = dec_ccsao(ctx); com_assert_rv(ret == COM_OK, ret); } #endif /* ALF */ if (ctx->info.sqh.adaptive_leveling_filter_enable_flag) { ret = dec_alf_avs2(ctx, ctx->pic); com_assert_rv(COM_SUCCEEDED(ret), ret); } /* MD5 check for testing encoder-decoder match*/ if (ctx->use_pic_sign && ctx->pic_sign_exist) { ret = dec_picbuf_check_signature(ctx->pic, ctx->pic_sign #if CU_LEVEL_PRIVACY , ctx->user_permission || !ctx->info.pic_header.ph_privacy_on #endif ); com_assert_rv(COM_SUCCEEDED(ret), ret); ctx->pic_sign_exist = 0; /* reset flag */ } #if SVAC_UD_MD5_STREAM extension_and_user_data(ctx, bs, 1, sqh, pic_header); if (ctx->use_pic_sign && ctx->stream_sign_exist) { ctx->stream_sign_check_flag = 1; unsigned char * concat_buf = malloc((1024 * 1024 * 32)); com_assert_rv(concat_buf != NULL, -1); unsigned int stream_size = (unsigned int)((u8 *)bitb->addr3 - (u8 *)bitb->addr3_beg); u8 * stream_p = bitb->addr3_beg; unsigned char * buffer_p = concat_buf; while ((stream_p - (u8 *)bitb->addr3_beg) < stream_size) { unsigned int nal_size = 1; while (!(stream_p[nal_size + 0] == 0x00 && stream_p[nal_size + 1] == 0x00 && stream_p[nal_size + 2] == 0x00 && stream_p[nal_size + 3] == 0x01) && !(stream_p[nal_size + 0] == 0x00 && stream_p[nal_size + 1] == 0x00 && stream_p[nal_size + 2] == 0x01 && stream_p[nal_size - 1] != 0)) { if (!((stream_p - (u8 *)bitb->addr3_beg) < stream_size - nal_size - 4)) { nal_size += 4; break; } nal_size++; } if (stream_p[4] != (0x0c) && stream_p[3] != (0x0c) //sei && stream_p[4] != (0x20) && stream_p[3] != (0x20) //eocvs && stream_p[4] != (0x16) && stream_p[3] != (0x16) //eos #if SVAC_SECURITY_PARAM_SET && stream_p[4] != (0x52) && stream_p[3] != (0x52) //sec #endif #if SVAC_AUTHENTICATION && stream_p[4] != (0x14) && stream_p[3] != (0x14) //auth #endif ) { int start_code_len = 4; if (stream_p[0] == 0x00 && stream_p[1] == 0x00 && stream_p[2] == 0x01) { start_code_len = 3; } unsigned int raw_nal_size = nal_size - start_code_len; memcpy(buffer_p, stream_p + start_code_len, raw_nal_size); buffer_p += raw_nal_size; } stream_p += nal_size; } int stream_total_size = (int)(buffer_p - concat_buf); u8 stream_sign[16]; int ret = com_md5_stream(concat_buf, stream_total_size, stream_sign); com_assert_rv(COM_SUCCEEDED(ret), ret); if (com_mcmp(ctx->stream_sign, stream_sign, 16) != 0) { printf("\n stream signature check failed \n"); } com_assert_rv(com_mcmp(ctx->stream_sign, stream_sign, 16) == 0, COM_ERR_BAD_CRC); ctx->stream_sign_exist = 0; /* reset flag */ if (concat_buf) free(concat_buf); } bitb->addr3 = bitb->addr3_beg; #endif #if PIC_PAD_SIZE_L > 0 /* expand pixels to padding area */ dec_picbuf_expand(ctx, ctx->pic); #endif #if LIB_PIC_MIXBIN } if (is_patch_l) { memcpy(ctx->libpic_pic_alf_on, ctx->pic_alf_on, N_C * sizeof(int)); for (int lcu_idx = 0; lcu_idx < ctx->info.f_lcu; lcu_idx++) { copy_sao_param_for_blk(ctx->libpic_sao_blk_params[lcu_idx], ctx->sao_blk_params[lcu_idx]); copy_sao_param_for_blk(ctx->libpic_rec_sao_blk_params[lcu_idx], ctx->rec_sao_blk_params[lcu_idx]); memcpy(ctx->dec_alf->libpic_alf_lcu_enabled[lcu_idx], ctx->dec_alf->alf_lcu_enabled[lcu_idx], N_C * sizeof(int)); } for (int comp_idx = 0; comp_idx < N_C; comp_idx++) { memcpy(ctx->libpic_esao_lcu_flag[comp_idx], ctx->info.pic_header.pic_esao_params[comp_idx].lcu_flag, ctx->info.f_lcu * sizeof(int)); if (comp_idx) memcpy(ctx->libpic_ccsao_lcu_flag[comp_idx - 1], ctx->info.pic_header.pic_ccsao_params[comp_idx - 1].lcu_flag, ctx->info.f_lcu * sizeof(int)); } } #endif /* put decoded picture to DPB */ #if LIBVC_ON if (sqh->library_stream_flag #if LIB_PIC_MIXBIN && (!is_patch_l || (is_patch_l && (ctx->patch->idx + 1) == ctx->patch->rows * ctx->patch->columns)) #endif ) { ret = com_picman_put_libpic(&ctx->dpm, ctx->pic, ctx->info.pic_header.slice_type, ctx->ptr, pic_header->decode_order_index, ctx->info.pic_header.temporal_id, 1, ctx->refp, pic_header #if HLS_OPT_PPS , pps #endif ); } else #if LIB_PIC_MIXBIN if (!sqh->library_stream_flag) #endif #endif { ret = com_picman_put_pic(&ctx->dpm, ctx->pic, ctx->info.pic_header.slice_type, ctx->ptr, pic_header->decode_order_index , pic_header->picture_output_delay, ctx->info.pic_header.temporal_id, 1, ctx->refp #if OBMC #if CUDQP , pic_header #else , pic_header->picture_qp #endif #if HLS_OPT_PPS , pps #endif #endif ); #if LIBVC_ON assert((&ctx->dpm)->cur_pb_size + (&ctx->dpm)->cur_libpb_size <= sqh->max_dpb_size); #else assert((&ctx->dpm)->cur_pb_size <= sqh->max_dpb_size); #endif } com_assert_rv(COM_SUCCEEDED(ret), ret); } #if SVAC_NAL else if (bs->cur[3] == SVAC_EOS) { ctx->init_flag = 0; ctx->libpic_init_flag = 0; cnkh->ctype = COM_CT_SEQ_END; } else if (bs->cur[3] == SVAC_EOCVS) { ctx->init_flag = 0; ctx->libpic_init_flag = 0; cnkh->ctype = COM_CT_CVS_END; } #endif #if SVAC_SECURITY_PARAM_SET else if (bs->cur[3] == SVAC_SEC_PS) { dec_eco_sec_parameter_set_init(ctx, bs, pic_header, sec_para_set); ret = dec_eco_sec_parameter_set(ctx, bs, pic_header, sec_para_set); com_assert_rv(COM_SUCCEEDED(ret), ret); cnkh->ctype = COM_CT_SEC_PARA_SET; } #endif #if SVAC_AUTHENTICATION else if (bs->cur[3] == SVAC_AUTH_DATA) { dec_eco_auth_data_init(ctx, bs, pic_header, auth_data); ret = dec_eco_auth_data(ctx, bs, pic_header, auth_data); com_assert_rv(COM_SUCCEEDED(ret), ret); cnkh->ctype = COM_CT_AUTH; } #endif else { return COM_ERR_MALFORMED_BITSTREAM; } make_stat(ctx, cnkh->ctype, stat); return ret; }
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值