History

avfilter/framepool: align the frame buffers

And not just the linesizes. Use the extra align bytes allocated for this purpose.

James Almer committed 2 years ago

Commit f15fc271 parent 6d5a0991 file · +8 −4Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/framepool.c+8−4
@@ -139,7 +139,9 @@ FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(size_t size), · 138 unmodified lines
139139 if (ret < 0)
140140 goto fail;
141141
142− pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL);
142+ if (pool->linesize[0] > SIZE_MAX - align)
143+ goto fail;
144+ pool->pools[0] = av_buffer_pool_init(pool->linesize[0] + align, NULL);
143145 if (!pool->pools[0])
144146 goto fail;
145147
@@ -219,7 +221,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) · 73 unmodified lines
219221 if (!frame->buf[i])
220222 goto fail;
221223
222− frame->data[i] = frame->buf[i]->data;
224+ frame->data[i] = (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
223225 }
224226
225227 if (desc->flags & AV_PIX_FMT_FLAG_PAL) {
@@ -256,13 +258,15 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) · 30 unmodified lines
256258 frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
257259 if (!frame->buf[i])
258260 goto fail;
259− frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
261+ frame->extended_data[i] = frame->data[i] =
262+ (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
260263 }
261264 for (i = 0; i < frame->nb_extended_buf; i++) {
262265 frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
263266 if (!frame->extended_buf[i])
264267 goto fail;
265− frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data;
268+ frame->extended_data[i + AV_NUM_DATA_POINTERS] =
269+ (uint8_t *)FFALIGN((uintptr_t)frame->extended_buf[i]->data, pool->align);
266270 }
267271
268272 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t