mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 16:50:10 +01:00
frontends/va: Ignore requested size when creating VAEncCodedBufferType
The buffer data is not directly accessible to application and it's internally used to only store VACodedBufferSegment struct. Ignore the size requested by application and instead allocate sizeof(VACodedBufferSegment). Use calloc to zero out the struct. This can save significant amount of memory, for example FFmpeg will request up to tens of MB for single buffer. Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6462 Reviewed-by: Thong Thai <thong.thai@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24410>
This commit is contained in:
parent
040a0fcf42
commit
7bcbfae87c
1 changed files with 5 additions and 2 deletions
|
|
@ -57,7 +57,11 @@ vlVaCreateBuffer(VADriverContextP ctx, VAContextID context, VABufferType type,
|
|||
buf->type = type;
|
||||
buf->size = size;
|
||||
buf->num_elements = num_elements;
|
||||
buf->data = MALLOC(size * num_elements);
|
||||
|
||||
if (buf->type == VAEncCodedBufferType)
|
||||
buf->data = CALLOC(1, sizeof(VACodedBufferSegment));
|
||||
else
|
||||
buf->data = MALLOC(size * num_elements);
|
||||
|
||||
if (!buf->data) {
|
||||
FREE(buf);
|
||||
|
|
@ -172,7 +176,6 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff)
|
|||
if (buf->type == VAEncCodedBufferType) {
|
||||
((VACodedBufferSegment*)buf->data)->buf = *pbuff;
|
||||
((VACodedBufferSegment*)buf->data)->size = buf->coded_size;
|
||||
((VACodedBufferSegment*)buf->data)->next = NULL;
|
||||
*pbuff = buf->data;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue