History

avfilter/framepool: use av_image_fill_plane_sizes() to calculate pool sizes

James Almer committed 4 years ago

Commit 8fcd9d71 parent 837c55d1 file · +14 −6Browse files

Unified · Split

libavfilter/framepool.c+14−6
@@ -57,6 +57,8 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size), · 56 unmodified lines
57 int i, ret;57 int i, ret;
58 FFFramePool *pool;58 FFFramePool *pool;
59 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);59 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
60 ptrdiff_t linesizes[4];
61 size_t sizes[4];
60 62
61 if (!desc)63 if (!desc)
62 return NULL;64 return NULL;
@@ -89,13 +91,19 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size), · 26 unmodified lines
89 }91 }
90 }92 }
91 93
92 for (i = 0; i < 4 && pool->linesize[i]; i++) {94 for (i = 0; i < 4; i++)
93 int h = pool->height;95 linesizes[i] = pool->linesize[i];
94 if (i == 1 || i == 2)
95 h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
96 96
97 pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + align,97 if (av_image_fill_plane_sizes(sizes, pool->format,
98 alloc);98 pool->height,
99 linesizes) < 0) {
100 goto fail;
101 }
102
103 for (i = 0; i < 4 && sizes[i]; i++) {
104 if (sizes[i] > SIZE_MAX - align)
105 goto fail;
106 pool->pools[i] = av_buffer_pool_init(sizes[i] + align, alloc);
99 if (!pool->pools[i])107 if (!pool->pools[i])
100 goto fail;108 goto fail;
101 }109 }

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