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 | if (ret < 0) | 139 | if (ret < 0) |
| 140 | goto fail; | 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 | if (!pool->pools[0]) | 145 | if (!pool->pools[0]) |
| 144 | goto fail; | 146 | goto fail; |
| 145 | 147 | ||
| @@ -219,7 +221,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) · 73 unmodified lines | |||
| 219 | if (!frame->buf[i]) | 221 | if (!frame->buf[i]) |
| 220 | goto fail; | 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 | if (desc->flags & AV_PIX_FMT_FLAG_PAL) { | 227 | if (desc->flags & AV_PIX_FMT_FLAG_PAL) { |
| @@ -256,13 +258,15 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) · 30 unmodified lines | |||
| 256 | frame->buf[i] = av_buffer_pool_get(pool->pools[0]); | 258 | frame->buf[i] = av_buffer_pool_get(pool->pools[0]); |
| 257 | if (!frame->buf[i]) | 259 | if (!frame->buf[i]) |
| 258 | goto fail; | 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 | for (i = 0; i < frame->nb_extended_buf; i++) { | 264 | for (i = 0; i < frame->nb_extended_buf; i++) { |
| 262 | frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]); | 265 | frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]); |
| 263 | if (!frame->extended_buf[i]) | 266 | if (!frame->extended_buf[i]) |
| 264 | goto fail; | 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 | break; | 272 | break; |