And not just the linesizes. Use the extra align bytes allocated for this purpose.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -139,7 +139,9 @@ FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(size_t size), · 138 unmodified lines | ||
| 139 | 139 | if (ret < 0) |
| 140 | 140 | goto fail; |
| 141 | 141 | |
| 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); | |
| 143 | 145 | if (!pool->pools[0]) |
| 144 | 146 | goto fail; |
| 145 | 147 | |
| @@ -219,7 +221,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) · 73 unmodified lines | ||
| 219 | 221 | if (!frame->buf[i]) |
| 220 | 222 | goto fail; |
| 221 | 223 | |
| 222 | − frame->data[i] = frame->buf[i]->data; | |
| 224 | + frame->data[i] = (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align); | |
| 223 | 225 | } |
| 224 | 226 | |
| 225 | 227 | if (desc->flags & AV_PIX_FMT_FLAG_PAL) { |
| @@ -256,13 +258,15 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) · 30 unmodified lines | ||
| 256 | 258 | frame->buf[i] = av_buffer_pool_get(pool->pools[0]); |
| 257 | 259 | if (!frame->buf[i]) |
| 258 | 260 | 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); | |
| 260 | 263 | } |
| 261 | 264 | for (i = 0; i < frame->nb_extended_buf; i++) { |
| 262 | 265 | frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]); |
| 263 | 266 | if (!frame->extended_buf[i]) |
| 264 | 267 | 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); | |
| 266 | 270 | } |
| 267 | 271 | |
| 268 | 272 | break; |