SDWebImage / SDWebImage/SDWebImageWebPCoder

Skipping frames for Animated WebP

未关闭
#61 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
Objective-C
星标
277
派生
101
PR 合并指标
30 天内没有已合并 PR

描述

It would be good to have an option to skip frames for animated webP.
If I have a thumbnail trying to render an animated wepb image with 120 frames it could be good to render only 30 frames, to preserve speed and memory.
Maybe not the first 30 frames but skipping frames in a loop: the animation will not be very smooth obviously.

A simple, not nice looking solution to skip half of the frames:
SDImageWebPCoder.m
line 264
Adding a skipper in the loop and duplicating the duration

    int skipper = 0;
    do {
        skipper++;
        if ((skipper %2) == 0) {
            continue;
        }
            
        @autoreleasepool {
            CGImageRef imageRef = [self sd_drawnWebpImageWithCanvas:canvas iterator:iter colorSpace:colorSpace scaledSize:scaledSize];
            if (!imageRef) {
                continue;
            }

#if SD_UIKIT || SD_WATCH
            UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
#else
            UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:kCGImagePropertyOrientationUp];
#endif
            CGImageRelease(imageRef);
            
            NSTimeInterval duration = [self sd_frameDurationWithIterator:iter];
            SDImageFrame *frame = [SDImageFrame frameWithImage:image duration:(duration*2)];
            [frames addObject:frame];
        }
        
    } while (WebPDemuxNextFrame(&iter));

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 SDImageWebPCoder.m 中大约第 264 行开始,这里会解码动画 WebP 帧并收集其持续时间。确定应如何在受支持的 Apple 平台上公开并保留一个选择性启用的帧跳过选项,然后使用动画 WebP fixture 验证最终的帧数和动画时序。

由索引模型根据 Issue 内容生成。

评估

技术栈
objective-c
领域
mobile-dev
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。