Skip to content

Commit 9a8689a

Browse files
committed
video player: use square BO
When uploading memory with size X into a dmabuf, create a buffer that is square (e.g. sqrt(x) by sqrt(x)) instead of one that is X pixels wide and one pixel high. Drivers have limitations on buffer dimensions, and e.g. the intel (iris) driver ran into this limitation.
1 parent c7e0ff5 commit 9a8689a

File tree

1 file changed

+12
-4
lines changed
  • src/plugins/gstreamer_video_player

1 file changed

+12
-4
lines changed

src/plugins/gstreamer_video_player/frame.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,18 @@ UNUSED int dup_gst_buffer_range_as_dmabuf(struct gbm_device *gbm_device, GstBuff
359359
return -1;
360360
}
361361

362-
bo = gbm_bo_create(gbm_device, map_info.size, 1, GBM_FORMAT_R8, GBM_BO_USE_LINEAR);
362+
// Create a square texture large enough to fit our bytes instead of one with only one huge row,
363+
// because some drivers have limitations on the row length. (Intel)
364+
uint32_t dim = (uint32_t) ceil(sqrt(map_info.size));
365+
366+
bo = gbm_bo_create(gbm_device, dim, dim, GBM_FORMAT_R8, GBM_BO_USE_LINEAR);
363367
if (bo == NULL) {
364368
LOG_ERROR("Couldn't create GBM BO to copy video frame into.\n");
365369
goto fail_unmap_buffer;
366370
}
367371

368372
map_data = NULL;
369-
map = gbm_bo_map(bo, 0, 0, map_info.size, 1, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
373+
map = gbm_bo_map(bo, 0, 0, dim, dim, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
370374
if (map == NULL) {
371375
LOG_ERROR("Couldn't mmap GBM BO to copy video frame into it.\n");
372376
goto fail_destroy_bo;
@@ -415,14 +419,18 @@ UNUSED int dup_gst_memory_as_dmabuf(struct gbm_device *gbm_device, GstMemory *me
415419
return -1;
416420
}
417421

418-
bo = gbm_bo_create(gbm_device, map_info.size, 1, GBM_FORMAT_R8, GBM_BO_USE_LINEAR);
422+
// Create a square texture large enough to fit our bytes instead of one with only one huge row,
423+
// because some drivers have limitations on the row length. (Intel)
424+
uint32_t dim = (uint32_t) ceil(sqrt(map_info.size));
425+
426+
bo = gbm_bo_create(gbm_device, dim, dim, GBM_FORMAT_R8, GBM_BO_USE_LINEAR);
419427
if (bo == NULL) {
420428
LOG_ERROR("Couldn't create GBM BO to copy video frame into.\n");
421429
goto fail_unmap_buffer;
422430
}
423431

424432
map_data = NULL;
425-
map = gbm_bo_map(bo, 0, 0, map_info.size, 1, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
433+
map = gbm_bo_map(bo, 0, 0, dim, dim, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
426434
if (map == NULL) {
427435
LOG_ERROR("Couldn't mmap GBM BO to copy video frame into it.\n");
428436
goto fail_destroy_bo;

0 commit comments

Comments
 (0)