惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
T
The Blog of Author Tim Ferriss
博客园 - 三生石上(FineUI控件)
博客园_首页
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
GbyAI
GbyAI
M
MIT News - Artificial intelligence
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
Recent Announcements
Recent Announcements
小众软件
小众软件
量子位
S
SegmentFault 最新的问题
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏

博客园 - ahuo

dts删除节点方法 Ubuntu ap桥接到有线 MQTT 3.1.1 客户端如何使用共享订阅 mdns shell Ubuntu笔记本盖上不休眠 win10+ubuntu24 双系统 http代理-docker拉取 Ubuntu20 IP显示登录界面 串口启用密码或者不用密码的配置方法(/etc/inittab) mkpasswd Linux下串口的RTS控制 万用表测量MCU的GPIO trackerslist Linux串口通讯监听-jpnevulator NV12数据转OpenCV的Mat Ubuntu 22 root桌面登录 Ubuntu22 向日葵黑屏 vscode ssh key登录 Samba 访问失败,提示“你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问。” Linux NAT转发
crop_yuv420_sp
ahuo · 2024-12-20 · via 博客园 - ahuo
void crop_yuv420_sp(unsigned char *srcbuf, int src_width, int src_height,
                    unsigned char *dstbuf, int x, int y, int w, int h) {
    int i;
    int dst_y_size = w * h;
    int dst_uv_size = (w / 2) * (h / 2);
    int src_y_line_size = src_width;
    int src_uv_line_size = src_width;

    // Crop Y component
    for (i = 0; i < h; i++) {
        memcpy(dstbuf + i * w, srcbuf + (y + i) * src_y_line_size + x, w);
    }

    // Crop UV component (interleaved)
    for (i = 0; i < h / 2; i++) {
        memcpy(dstbuf + dst_y_size + i * w, srcbuf + src_y_line_size * src_height + ((y / 2) + i) * src_uv_line_size + (x / 2) * 2, w);
    }
}