x264 i_thead

最近需要用到x264编码库,在安卓手机上在i_thead=1的时候,CPU使用率最多到30多,编码效率很低,640*480的分辨率都很费劲,所以想要使用x264的多线程。


i_thead = N时,需要注意,


b_sliced_threads = 1,多线程编码出来的是slice并行,但是这个有点时无延时,但是,如果需要将h264再进行处理不好处理,例如打包mp4等。


b_sliced_threads  = 0,多线程编码出来的是frame并行,有少许延时,但是,好处理,编码出来的frame

资源分类bin目录 本文解析的是图库类型,配置没什么必要性,在做特效时自行修改就可以了。图库总共7个(有一个重复,实际只有6个) 类型 名字 对应索引 动画配置 Anime_3 AnimeInfo_3 动画配置 Anime_Joy_13 AnimeInfo_Joy_13 动画配置 AnimeEx_1 AnimeInfoEx_1 动画配置 AnimeV3_7 AnimeInfoV3_7 动画配置 Puk2\Anime_PUK2_4 Puk2\AnimeInfo_PUK2_4 动画配置 Puk3\Anime_PUK3_2 Puk3\AnimeInfo_PUK3_2 ??动画配置 AnimeAp AnimeApdd ??战斗调色板 battle_4 battletxt_4 坐标信息 coordinatev3_2 coordinateinfov3_2 声音配置 sound_1 soundaddr_1 图库 Graphic_20 GraphicInfo_20 图库 GraphicEx_4 GraphicInfoEx_4 图库 Graphic_Joy_22 GraphicInfo_20 图库 GraphicV3_18 GraphicInfoV3_18 图库 Puk2\Graphic_PUK2_2 Puk2\GraphicInfo_PUK2_2 图库同Puk2 Puk3\Graphic_PUK2_2 Puk3\GraphicInfo_PUK2_2 图库 Puk3\Graphic_PUK3_1 Puk3\GraphicInfo_PUK3_1 调色板 bin\pal\*.cgp 无 调色板格式 调色板文件固定长度708字节,每个颜色3个字节,总共236个颜色。 游戏中0-15号,240-255号颜色有固定的默认值。调色板实际占据的是16-239号 例如图片使用的调色板为16号颜色,也就是对应调色板文件中的0号颜色。取出字节1(Blue)、字节2(Green)、字节3(Red),自行拼配颜色即可。 本程序默认使用palet_08调色板。 ———————————————— // 索引文件数据块 struct imgInfoHead { unsigned int id; unsigned int addr; // 在图像文件中的偏移 unsigned int len; // 长度 long xOffset; // 在游戏内的偏移量x long yOffset; // 在游戏内的偏移量y unsigned int width; unsigned int height; unsigned char tileEast; // 地图上横向几格 unsigned char tileSouth;// 竖向几格 unsigned char flag; unsigned char unKnow[5]; long tileId; // 所属的地图tile的id }; 索引文件每一张图片包含40个字节的字段。索引文件/40就是总图片数。实际上读取这个索引文件对图片提取没有太大意义,里面的几个字段主要是用于地图的拼接。 图库格式 // 图像bin 文件格式 struct imgData { unsigned char cName[2]; unsigned char cVer; // 1压缩 unsigned char cUnknow; unsigned int width; unsigned int height; unsigned int len; // 包含自身头的总长度,后续跟char数组 }; // + char* len = size - 16 每一张图片都有数据头,而且因为是顺序存储,实际上可以不使用索引文件的。 一张完整的图片包含 数据头+图片数据。 cVer说明: 0:未压缩,后续的数据就是图片数据 1:压缩,需要对后续数据进行解压 3:带调色板的压缩。在读取文件头后,还需要再读入4个字节,这4个字节代表调色板解压后的长度。 取图步骤 读取索引数据 FILE *pFile = nullptr; std::string strPath = _strPath + "\\bin\\"; if (0 == fopen_s(&pFile, (strPath + strInfo).c_str(), "rb")) { imgInfoHead tHead = { 0 }; int len = sizeof(imgInfoHead); while (len == fread_s(&tHead, len, 1, len, pFile)) _vecImginfo.push_back(tHead); } if (pFile) fclose(pFile); ———————————————— 遍历索引读取对应图库数据头 imgData tHead = { 0 }; int len = sizeof(imgData); if (len == fread_s(&tHead, len, 1, len, pFile)) { // 这种是错误的图 if (tHead.width > 5000 || tHead.height > 5000) { saveLog(LOG_ERROR, strErrorFile, strName, "img w or h error", imgHead, tHead); return false; } _cgpLen = 0; // 调色板长度 if (tHead.cVer == 3) { // 多读取4个字节,代表的是调色板的长度 if (4 != fread_s(&_cgpLen, 4, 1, 4, pFile)) { saveLog(LOG_ERROR, strErrorFile, strName, "read cgpLen error", imgHead, tHead); return false; } len += 4; } .... } ———————————————— 解密后续数据 if (imgLen == fread_s(_imgEncode, imgLen, 1, imgLen, pFile)) { if (tHead.cVer == 0) { // 未压缩图片 _imgDataIdx = imgLen; memcpy(_imgData, _imgEncode, imgLen); } else if (tHead.cVer == 1 || tHead.cVer == 3) { // 压缩的图片 _imgDataIdx = decodeImgData(_imgEncode, imgLen); if (_imgDataIdx != tHead.width * tHead.height + _cgpLen) { // 这种情况按说是错的 if (_imgDataIdx < tHead.width * tHead.height + _cgpLen) { saveLog(LOG_ERROR, strErrorFile, strName, "decode len more", imgHead, tHead); return false; } else { // 大于的话应该算是不够严谨 saveLog(LOG_INFO, strErrorFile, strName, "decode len less", imgHead, tHead); } } } } ———————————————— 填充像素 // 默认使用palet_08.cgp(白天) 调色版 unsigned char *pCgp = _uMapCgp.begin()->second.data(); strCgpName = _uMapCgp.begin()->first; // 使用图片自带调色板 if (_cgpLen > 0 && (int)_imgDataIdx >= w * h + _cgpLen) { pCgp = _imgData + (_imgDataIdx - _cgpLen); strCgpName = "self"; } // 图片数据,竖向方向是反的,从最后一行开始 int imgLen = w * h; for (int i = 0; i < imgLen; ++i) { // 调色板编号 int cIdx = _imgData[i] * 3; int idx = (h - i / w - 1) * w + i % w; _imgPixel[idx] = (pCgp[cIdx]) + (pCgp[cIdx + 1] << 8) + (pCgp[cIdx + 2] << 16); if (pCgp[cIdx] != 0 || pCgp[cIdx + 1] != 0 || pCgp[cIdx + 2] != 0) _imgPixel[idx] |= 0xff000000; } ———————————————— 生成图片 Gdiplus::Bitmap bmp(w, h, PixelFormat32bppARGB); int idx = 0; for (int row = 0; row < h; ++row) { for (int col = 0; col < w; ++col) { bmp.SetPixel(col, row, p[idx++]); } } CLSID encoderClsid; std::wstring s = L"image/" + wstrExt; if (!GetEncoderClsid(s.c_str(), &encoderClsid)) { return false; } std::wstring sName = wstrName + L"." + wstrExt; bmp.Save(sName.c_str(), &encoderClsid, nullptr); ———————————————— 依照內容生成BIN檔提取圖片工具 魔力宝贝高清单机计划(一) 图库提取 https://blog.youkuaiyun.com/qq_37543025/article/details/88377553
最新发布
07-07
#模块导入 from selenium import webdriver from time import sleep from lxml import etree import xlwt import openpyxl #初始化 ##浏览器部分 bro = webdriver.Chrome() bro.get("https://china.nba.cn/players/stats/#!/stephen_curry") page_text = bro.page_source sleep(5) bro.quit() tree=etree.HTML(page_text) ##表格数据部分 file=xlwt.Workbook() sheet1 = file.add_sheet('sheet1',cell_overwrite_ok=True) line_per=[] #数据爬取函数准备 def score_record(x): tree_line=tree.xpath(x) line_0=[] for i in tree_line: tree_line_word=i.xpath('.//text()') for i in tree_line_word: if i.strip(): line_0.append(i.strip()) line_true=[line_0[0],line_0[18],line_0[19],line_0[20],line_0[21],line_0[22],line_0[23]] line_per.append(line_true) #爬取数据 a='/html/body/div[5]/div/div/div/div[2]/div[2]/section/div/div[2]/div[2]/div[1]/div[1]/div[3]/nba-stat-table/div/div[1]/table/thead/tr' score_record(a) for i in range(1,14): webside='/html/body/div[5]/div/div/div/div[2]/div[2]/section/div/div[2]/div[2]/div[1]/div[1]/div[3]/nba-stat-table/div/div[1]/table/tbody/tr[{}]'.format(i) score_record(webside) #保存数据 file = xlwt.Workbook() sheet1 = file.add_sheet('sheet1',cell_overwrite_ok=True) for j in range(0,14): for i in range(0,7): sheet1.write(j,i,line_per[j][i]) file.save('python结课程序.xls') #分析数据 sheet1.write(0,7,"两分出手") sheet1.write(0,8,"两分命中") wb = openpyxl.load_workbook('python结课程序.xls') sheet = wb['sheet1'] for i in range(2, 15): c_val = sheet.cell(row=i, column=3).value e_val = sheet.cell(row=i, column=5).value g_val = sheet.cell(row=i, column=7).value result = c_val - e_val - g_val sheet.cell(row=i, column=8).value = result for i in range(2, 15): b_val = sheet.cell(row=i, column=2).value d_val = sheet.cell(row=i, column=4).value f_val = sheet.cell(row=i, column=6).value result = b_val - d_val - f_val sheet.cell(row=i, column=9).value = result wb.save('python结课程序.xls')
06-11
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>收费项目列表</title> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.6.8/css/layui.css"> <style> .x-nav { padding: 0 20px; position: relative; z-index: 99; border-bottom: 1px solid #e5e5e5; line-height: 60px; } .x-body { padding: 20px; } .layui-table td, .layui-table th { padding: 9px 15px; } .td-manage a { margin: 0 5px; } .dialog-mask { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; display: flex; justify-content: center; align-items: center; } .dialog-content { background: #fff; padding: 20px; border-radius: 5px; width: 800px; max-height: 90vh; overflow-y: auto; } .x-red { color: red; } </style> </head> <body> <div id="app"> <!-- 面包屑导航 --> <div class="x-nav"> <span class="layui-breadcrumb"> <a>首页</a> <a>收费管理</a> <a><cite>收费项目列表</cite></a> </span> <a class="layui-btn layui-btn-sm" style="float:right" href="javascript:location.replace(location.href)" @click="refresh"> <i class="layui-icon layui-icon-refresh"></i> 刷新 </a> </div> <div class="x-body"> <!-- 操作栏 --> <div class="layui-row"> <a class="layui-btn" href="pro_add.html"> <i class="layui-icon layui-icon-add-1"></i> 添加收费项目 </a> </div> <!-- 数据表格 --> <table class="layui-table"> <thead> <tr> <th>ID</th> <th>所属小区</th> <th>收费编号</th> <th>项目名称</th> <th>创建时间</th> </tr> </thead> <tbody> <tr v-for="(item, index) in prolist" :key="item.id"> <td>{{ item.id }}</td> <td>{{ item.x_id }}</td> <td>{{ item.m_count }}</td> <td>{{ item.m_name }}</td> <td>{{ item.creat_Time }}</td> <td class="td-manage"> <a @click="editItem(index)" title="编辑"> <i class="layui-icon layui-icon-edit"></i> </a> <a @click="deleteItem(index)" title="删除"> <i class="layui-icon layui-icon-delete"></i> </a> </td> </tr> </tbody> </table> </div> <!-- 编辑弹框 --> <div v-if="dialogVisible" class="dialog-mask"> <div class="dialog-content"> <h3>{{ dialogTitle }}</h3> <form class="layui-form layui-form-pane"> <input type="hidden" v-model="formData.id"> <div class="layui-form-item"> <label class="layui-form-label"> <span class='x-red'>*</span>所属小区 </label> <div class="layui-input-block"> <input type="text" v-model="formData.x_id" placeholder="请输入所属小区编号" class="layui-input" lay-verify="required"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label"> <span class='x-red'>*</span>收费名称 </label> <div class="layui-input-block"> <input type="text" v-model="formData.m_name" placeholder="请输入项目名称" class="layui-input" lay-verify="required"> </div> </div> <div class="layui-form-item"> <button class="layui-btn layui-btn-primary" type="button" @click="dialogVisible = false">取消</button> <button class="layui-btn" type="button" @click="submitForm">确定</button> </div> </form> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script> <script src="https://www.layuicdn.com/layui-v2.6.8/layui.js"></script> <script> // 从localStorage获取房产数据 function getproData() { const data = localStorage.getItem('proData'); return data ? JSON.parse(data) : [ { id: '3', x_id: '1', m_count: 'A栋', m_name: '金华小区A栋', create_Time: '2019-12-13' }, { id: '2', x_id: '2', m_count: 'A栋', m_name: '金华小区A栋', create_Time: '2019-12-11' }, { id: '1', x_id: '3', m_count: 'A栋', m_name: '金华小区A栋', create_Time: '2019-12-12' } ]; } new Vue({ el: '#app', data: { proList: getproData(), dialogVisible: false, dialogTitle: '编辑收费项目', currentIndex: -1, formData: { id: '', x_id: '', m_count: '', m_name: '', create_Time: '' } }, mounted() { this.initLayui(); }, methods: { initLayui() { layui.use(['form', 'laydate', 'layer'], () => { const form = layui.form; const laydate = layui.laydate; window.layer = layui.layer; form.render(); laydate.render({ elem: '#checkInDate', max: '2099-12-31', done: (value) => { this.formData.create_Time = value; } }); }); }, refresh() { this.proList = getproData(); layer.msg('刷新成功', {icon: 1}); }, editItem(index) { this.dialogTitle = '编辑收费项目'; this.currentIndex = index; this.formData = JSON.parse(JSON.stringify(this.proList[index])); this.dialogVisible = true; this.$nextTick(() => { layui.form.render(); // 重新初始化日期选择器,确保显示正确的日期 layui.laydate.render({ elem: '#checkInDate', max: '2099-12-31', value: this.formData.create_Time, done: (value) => { this.formData.create_Time = value; } }); }); }, deleteItem(index) { const _this = this; layer.confirm('确定要删除这条记录吗?', function(){ _this.proList.splice(index, 1); localStorage.setItem('houseData', JSON.stringify(_this.proList)); layer.msg('删除成功', {icon: 1}); }); }, submitForm() { const form = layui.form; // 验证表单 form.verify(); if (!this.validateForm()) { return; } // 编辑 this.proList.splice(this.currentIndex, 1, this.formData); // 保存到localStorage localStorage.setItem('proData', JSON.stringify(this.proList)); this.dialogVisible = false; layer.msg('编辑成功', {icon: 1}); }, validateForm() { if (!this.formData.x_id) { layer.msg('请输入所属小区', {icon: 5}); return false; } if (!this.formData.m_name) { layer.msg('请输入名称', {icon: 5}); return false; } if (!this.formData.m_name) { layer.msg('项目名称不能为空', {icon: 5}); return false; } return true; }, } }); </script> </body> </html> 表单无法显示数据,写出更改后的代码
07-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值