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

推荐订阅源

C
Check Point Blog
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Docker
腾讯CDC
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
Vercel News
Vercel News
P
Proofpoint News Feed
雷峰网
雷峰网
博客园_首页
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
V
V2EX
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog
S
SegmentFault 最新的问题

博客园 - 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);
    }
}