No reason to allocate 16 when 3 will do.
Unified · Split
| @@ -1176,8 +1176,8 @@ const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt) · 1175 unmodified lines | ||
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | typedef struct ImageViewCtx { |
| 1179 | − VkImageView views[AV_NUM_DATA_POINTERS]; | |
| 1180 | 1179 | int nb_views; |
| 1180 | + VkImageView views[]; | |
| 1181 | 1181 | } ImageViewCtx; |
| 1182 | 1182 | |
| 1183 | 1183 | static void destroy_imageviews(void *opaque, uint8_t *data) |
| @@ -1206,7 +1206,8 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 22 unmodified lines | ||
| 1206 | 1206 | const int nb_images = ff_vk_count_images(vkf); |
| 1207 | 1207 | const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format); |
| 1208 | 1208 | |
| 1209 | − ImageViewCtx *iv = av_mallocz(sizeof(*iv)); | |
| 1209 | + const size_t buf_size = sizeof(int) + nb_planes*sizeof(VkImageView); | |
| 1210 | + ImageViewCtx *iv = av_mallocz(buf_size); | |
| 1210 | 1211 | if (!iv) |
| 1211 | 1212 | return AVERROR(ENOMEM); |
| 1212 | 1213 | |
| @@ -1243,7 +1244,7 @@ int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, · 30 unmodified lines | ||
| 1243 | 1244 | iv->nb_views++; |
| 1244 | 1245 | } |
| 1245 | 1246 | |
| 1246 | − buf = av_buffer_create((uint8_t *)iv, sizeof(*iv), destroy_imageviews, s, 0); | |
| 1247 | + buf = av_buffer_create((uint8_t *)iv, buf_size, destroy_imageviews, s, 0); | |
| 1247 | 1248 | if (!buf) { |
| 1248 | 1249 | err = AVERROR(ENOMEM); |
| 1249 | 1250 | goto fail; |