void S1mmeSession::CtEncodeKqi(S1MMEKQI* kqi, S1APNode* p_node, uint8_t worker_id) { MsgCommonInfo& common = p_node->GetCommonInfo(); SPUserInfo& sp_user_info = p_node->GetUserInfo(); //获取 buf TlvEncoder* p_encoder_cur = g_p_encoder_[worker_id]; YdCDR_T* p_dst_data = (YdCDR_T*)malloc(sizeof(YdCDR_T)); if (p_dst_data == NULL) { return; } p_dst_data->not_associate = 0; if ((common.not_associate & 0x03) == 0x03) p_dst_data->not_associate = 1; p_encoder_cur->Set(p_dst_data->cdr_data,kMaxOneCdrBufLen); uint64_t imsi = sp_user_info->GetIMSI(); if(common.eci == 0) { common.eci = sp_user_info->GetEci(); } uint16_t tmp_enbid = common.tac;//>>8; //uint32_t tmp_enbid = (common.eci >> 8)&0xfffff; char xdrid_str[32]={0}; #ifdef OPEN_NEW_HUISU convert_xdrid_to_string(xdrid_str, kqi->xdrid, s_xdr_id_len); #else #ifdef OPENCTPR g4sigtran::pr::ProcBlock* p_blk = kqi->binary_block_in_xdr_.GetBlock(); p_blk->SerializeXid(xdrid_str, sizeof(xdrid_str)); #else uint64_t subcdrid = g_ct_xdr_id.GetXid(); //reverse subend; if(::is_open_reverse) { SetReverseSubend(p_node, subcdrid); } #ifdef ONE_THIRD_YUNNAN_MRO g_ct_xdr_id.Serialize((uint8_t*)xdrid_str, s_xdr_id_len, imsi); #else g_ct_xdr_id.Serialize((uint8_t*)xdrid_str, s_xdr_id_len); #endif #endif #endif struct timespec start_time = kqi->request_time_, end_time = kqi->response_time_; if (kqi->request_time_.tv_sec == 0) { if (!(kqi->response_time_.tv_sec == 0)) { start_time = kqi->response_time_; } else if (!(kqi->complete_time_.tv_sec == 0)) { start_time = kqi->complete_time_; } }要求:在S1mmeSession::CtEncodeKqi函数后面新加一个函数,来维护一组key、value的关系。 key为:imsi value为:imsi、imei、common.eci、common.tac、last_time 当imsi相同时,以最后一条记录的value内容为准进行保存;imsi不同时直接插入。请用C++实现该功能,需要用到哈希的知识点
时间: 2024-03-29 12:39:31 浏览: 149
SDCycleScrollView-master.zip_KQI_SDCycleScrollView_oc 轮播图框架_轮播图
像进行JPEG解压缩,并将解压缩后的图像存储到视频文件中。
```matlab
outputVideo =好的,根据您的要求,我可以为您提供以下C++代码来实现所需功能,其中使用了哈希表来维护key-value关系:
#include <unordered_map>
#include <ctime>
struct KqiInfo {
uint64 VideoWriter('compressed.avi');
open(outputVideo);
for k = 1:numFrames
decoded_img = decoded_imgs{k};
% 调_t imsi;
uint64_t imei;
uint32_t eci;
uint16_t tac;
timespec last_time;
};
std::unordered_map<uint64_t, KqiInfo> kqi_map;
void update_kqi_map(S1MMEKQI用jpegdec函数进行JPEG解压缩
img = jpegdec(decoded_img);
writeVideo(outputVideo,img);
end
close(output* kqi, S1APNode* p_node) {
MsgCommonInfo& common = p_node->GetCommonInfo();
SPUserInfo& sp_user_info = p_node->GetUserInfo();
uint64_t imsi = sp_user_info->GetIMSI();
uintVideo);
```
完整的代码如下:
```matlab
% 读取视频文件并将每一帧图像进行64_t imei = sp_user_info->GetIMEI();
uint32_t eci = common.eci;
uint16_t tacJPEG压缩
vidObj = VideoReader('sample.avi');
numFrames = vidObj.NumberOfFrames;
for k = 1:numFrames = common.tac;
timespec now;
clock_gettime(CLOCK_REALTIME, &now);
KqiInfo kqi_info = {imsi, imei, eci, tac, now};
kqi_map[imsi] = kqi_info;
}
在
img = read(vidObj, k);
compressed_img = jpegenc(img); % 调用jpegenc函数进行JPEG压缩原有的S1mmeSession::CtEncodeKqi函数中,调用update_kqi_map函数即可将相关信息保存到哈希表中。如果imsi已经存在,会自动覆盖原有记录;如果imsi不存在,则新,返回压缩后的图像
% 将压缩后的图像存储到数组中,用于后续的建一条记录。需要注意的是,本代码中使用的哈希表默认使用std::hash函数进行哈希,如果需要自定义哈希函数可以通过std::unordered_map的第三个模板参数传入。
阅读全文