图库: 阅读器页槽改 RGB565 常驻,页图内存减半(M32)
- 页槽从 RGBA 改成「已落框的 RGB565 位图」(2B/px):真机 480×853 页 1599KB → 800KB, 两页常驻 3.2MB → 1.6MB。解码仍在 worker 里产出 RGBA,当场转 565 并释放 RGBA。 - SDK 新增 565 原语(meow_ui_draw.h / meow_ui_gfx.c):meow_gfx_blit_rgb565 命中页每行 一次 memcpy(单次拷贝、无每帧重采样),缩放兜底走 565 最近邻。量化与 back_buf 用同一个 rgb565(),565 屏上落下的像素与旧 RGBA 路径逐像素一致(不引入色偏/新增色带)。 - 预算按 565 重算:单页像素上限沿用旧 3MB@RGBA 的同几何口径(=1.5MB@565), MR_RESIDENT_CAP = 3 槽 + 1 张在途 = 3.2MB;reader_estimate_peak 新增 convert_bytes (落槽暂存 2B/px)与 peak_bytes 一起参与门控,避免实测超预算。 - 结果队列(已解码、未落槽)字节计入总预算(pending_bytes),不再「偷吃」最多 2 页。 - CBZ meta() 改读条目 4KB 前缀(mz_read_prefix;deflate 解到 4KB 即停,输入缓冲走栈), 500 页排版不再触发 500 次全量解压。 - 测试:B3/B8 的 565 常驻与在途预算断言、CBZ 500 页 stored/deflate 前后对比、 P12 565 与 RGBA 路径的逐像素颜色对比(量化误差/RMSE/灰阶梯)。
This commit is contained in:
1 parent
bbc73635a6
commit
7036020005
11 files changed
+910
-111
No files matched your search
@@ -4,7 +4,8 @@
|
||||
* - 页表在 init 时一次建好(mz_open 只读 central directory;只看名字,不解压);
|
||||
* - open(i) 才解压单条目:mz_read_alloc → page_cache 落盘 → 注入的解码回调按路径解码。
|
||||
* 因此翻页/条漫两套消费代码与目录册完全一致(meta 走原始像素尺寸,open 走解码);
|
||||
* - meta(i) 按需解压该页到内存只读图片头(不落缓存),结果缓存在 meta_w/meta_h;
|
||||
* - meta(i) 只读该条目的**前 4KB**(mz_read_prefix)取图片头(不落缓存),结果缓存在
|
||||
* meta_w/meta_h;M32 前是整条目解压,500 页排版 = 500 次全量解压;
|
||||
* - 单个 mr_zip_book 的 mz_read* 由自带的互斥量串行化(解码线程与主线程 meta 会碰面)。
|
||||
*
|
||||
* 线程:count/page_name 只读页表,可任意线程;open 可由解码线程调用;meta 按 M6
|
||||
@@ -269,7 +270,38 @@ static int zip_ops_count(void *ctx)
|
||||
return zb ? zb->count : 0;
|
||||
}
|
||||
|
||||
/* meta 按需解压头探测;结果缓存,每页只解压一次。主线程调用(M6 用法)。 */
|
||||
/* meta 只读条目**前缀**(≤4KB)取图片头(M32):改前是 mz_read_alloc 整条目解压后再探
|
||||
* (500 页排版 = 500 次全量解压)。PNG IHDR 33 字节、JPEG SOF 在头几百字节、BMP 在
|
||||
* 54 字节 + 调色板内,4KB 足够;前缀探测失败且确实被截断时才回退整条目读(罕见/病态文件)。 */
|
||||
#define MR_ZIP_META_PREFIX 4096
|
||||
|
||||
static int zip_meta_probe_prefix(mr_zip_book *zb, const mz_entry *e, int *w, int *h)
|
||||
{
|
||||
unsigned char head[MR_ZIP_META_PREFIX];
|
||||
size_t head_len = 0;
|
||||
pthread_mutex_lock((pthread_mutex_t *)zb->lock);
|
||||
int rc = mz_read_prefix((mz_archive *)zb->arch, e, head, sizeof head, &head_len);
|
||||
pthread_mutex_unlock((pthread_mutex_t *)zb->lock);
|
||||
if (rc != MZ_OK) return 0;
|
||||
if (mr_probe_size_mem(head, head_len, w, h)) return 1;
|
||||
if (head_len < sizeof head) return 0; /* 整个条目都读到了还探不出 → 坏头 */
|
||||
|
||||
/* 前缀被截断且探不出尺寸(病态长的头部):回退整条目读,保持旧语义。 */
|
||||
void *buf = NULL;
|
||||
size_t len = 0;
|
||||
pthread_mutex_lock((pthread_mutex_t *)zb->lock);
|
||||
rc = mz_read_alloc((mz_archive *)zb->arch, e, &buf, &len);
|
||||
pthread_mutex_unlock((pthread_mutex_t *)zb->lock);
|
||||
if (rc != MZ_OK || !buf) {
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
int known = mr_probe_size_mem(buf, len, w, h);
|
||||
free(buf);
|
||||
return known;
|
||||
}
|
||||
|
||||
/* meta 按需探测图片头;结果缓存,每页只读一次(前缀 4KB,不再整页解压)。主线程调用(M6 用法)。 */
|
||||
static int zip_ops_meta(void *ctx, int index, int *w, int *h)
|
||||
{
|
||||
mr_zip_book *zb = (mr_zip_book *)ctx;
|
||||
@@ -297,19 +329,8 @@ static int zip_ops_meta(void *ctx, int index, int *w, int *h)
|
||||
const mz_entry *e = page_entry(zb, index);
|
||||
if (!e) return 0;
|
||||
|
||||
pthread_mutex_lock((pthread_mutex_t *)zb->lock);
|
||||
void *buf = NULL;
|
||||
size_t len = 0;
|
||||
int rc = mz_read_alloc((mz_archive *)zb->arch, e, &buf, &len);
|
||||
pthread_mutex_unlock((pthread_mutex_t *)zb->lock);
|
||||
if (rc != MZ_OK || !buf) {
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
int pw = 0, ph = 0;
|
||||
int known = mr_probe_size_mem(buf, len, &pw, &ph);
|
||||
free(buf);
|
||||
if (!known) return 0;
|
||||
if (!zip_meta_probe_prefix(zb, e, &pw, &ph)) return 0;
|
||||
|
||||
zb->meta_w[index] = pw;
|
||||
zb->meta_h[index] = ph;
|
||||
|
||||
Reference in new issue
Block a user