drm_mode_fb_cmd2的handles[0]、handles[1]、handles[2]、handles[3]计算XYUV8888,已知weight、height和handle[0]
时间: 2023-10-07 12:11:08 浏览: 146
根据已知的 handle[0],可以使用 DRM API 中的 drmModeGetFB2 函数获取对应帧缓存的信息,包括 handles、pitches、offsets 等参数。例如,可以按照如下方式获取 XYUV8888 格式的帧缓存信息:
```
drmModeFBPtr fb = drmModeGetFB2(drm_fd, handle[0]);
if (!fb) {
fprintf(stderr, "failed to get framebuffer: %s\n", strerror(errno));
return -1;
}
if (fb->format != DRM_FORMAT_XYUV8888) {
fprintf(stderr, "unsupported pixel format: %d\n", fb->format);
drmModeFreeFB(fb);
return -1;
}
uint32_t width = fb->width;
uint32_t height = fb->height;
uint32_t handles[4], pitches[4], offsets[4];
handles[0] = fb->handle;
handles[1] = fb->handle;
handles[2] = fb->handle;
handles[3] = fb->handle;
pitches[0] = fb->pitch;
pitches[1] = fb->pitch;
pitches[2] = fb->pitch;
pitches[3] = fb->pitch;
offsets[0] = 0;
offsets[1] = 0;
offsets[2] = width * height * 4;
offsets[3] = width * height * 4;
```
其中,drm_fd 是打开 DRM 设备文件的文件描述符。handles、pitches、offsets 数组的含义与上面的回答一致,这里不再赘述。
需要注意的是,这里假设帧缓存中的所有分量都存储在同一个缓冲区中,因此 handles 数组中的四个元素都是 fb->handle。如果实际情况下 X、Y、U、V 四个分量存储在不同的缓冲区中,那么需要分别获取这四个缓冲区的句柄,并将它们存储在 handles 数组中。
阅读全文
相关推荐


















