| 464 | } |
| 465 | |
| 466 | int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, |
| 467 | int width, int height, int align) |
| 468 | { |
| 469 | int ret, i; |
| 470 | int linesize[4]; |
| 471 | ptrdiff_t aligned_linesize[4]; |
| 472 | size_t sizes[4]; |
| 473 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); |
| 474 | if (!desc) |
| 475 | return AVERROR(EINVAL); |
| 476 | |
| 477 | ret = av_image_check_size(width, height, 0, NULL); |
| 478 | if (ret < 0) |
| 479 | return ret; |
| 480 | |
| 481 | ret = av_image_fill_linesizes(linesize, pix_fmt, width); |
| 482 | if (ret < 0) |
| 483 | return ret; |
| 484 | |
| 485 | for (i = 0; i < 4; i++) |
| 486 | aligned_linesize[i] = FFALIGN(linesize[i], align); |
| 487 | |
| 488 | ret = av_image_fill_plane_sizes(sizes, pix_fmt, height, aligned_linesize); |
| 489 | if (ret < 0) |
| 490 | return ret; |
| 491 | |
| 492 | ret = 0; |
| 493 | for (i = 0; i < 4; i++) { |
| 494 | if (sizes[i] > INT_MAX - ret) |
| 495 | return AVERROR(EINVAL); |
| 496 | ret += sizes[i]; |
| 497 | } |
| 498 | return ret; |
| 499 | } |
| 500 | |
| 501 | int av_image_copy_to_buffer(uint8_t *dst, int dst_size, |
| 502 | const uint8_t * const src_data[4], |