int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
                   int w, int h, enum AVPixelFormat pix_fmt, int align)
{
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
    int i, ret;
    uint8_t *buf;
    if (!desc)
        return AVERROR(EINVAL);
    if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)
        return ret;
    if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, align>7 ? FFALIGN(w, 8) : w)) < 0)
        return ret;
    for (i = 0; i < 4; i++)
        linesizes[i] = FFALIGN(linesizes[i], align);
    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)
        return ret;
    buf = av_malloc(ret + align);
    if (!buf)
        return AVERROR(ENOMEM);
    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {
        av_free(buf);
        return ret;
    if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
        avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
    return ret;
int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
                   int w, int h, enum AVPixelFormat pix_fmt, int align)
{
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
    int i, ret;
    uint8_t *buf;
    if (!desc)
        return AVERROR(EINVAL);
    if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)
        return ret;
    if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, align>7 ? FFALIGN(w, 8) : w)) < 0)
        return ret;
    for (i = 0; i < 4; i++)
        linesizes[i] = FFALIGN(linesizes[i], align);
    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)
        return ret;
    buf = av_malloc(ret + align);
    if (!buf)
        return AVERROR(ENOMEM);
    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {
        av_free(buf);
        return ret;
    if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
        avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
    return ret;
int FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],
                   int VAR_2, int VAR_3, enum AVPixelFormat VAR_4, int VAR_5)
{
    const AVPixFmtDescriptor *VAR_6 = av_pix_fmt_desc_get(VAR_4);
    int VAR_7, VAR_8;
    uint8_t *buf;
    if (!VAR_6)
        return AVERROR(EINVAL);
    if ((VAR_8 = av_image_check_size(VAR_2, VAR_3, 0, NULL)) < 0)
        return VAR_8;
    if ((VAR_8 = av_image_fill_linesizes(VAR_1, VAR_4, VAR_5>7 ? FFALIGN(VAR_2, 8) : VAR_2)) < 0)
        return VAR_8;
    for (VAR_7 = 0; VAR_7 < 4; VAR_7++)
        VAR_1[VAR_7] = FFALIGN(VAR_1[VAR_7], VAR_5);
    if ((VAR_8 = av_image_fill_pointers(VAR_0, VAR_4, VAR_3, NULL, VAR_1)) < 0)
        return VAR_8;
    buf = av_malloc(VAR_8 + VAR_5);
    if (!buf)
        return AVERROR(ENOMEM);
    if ((VAR_8 = av_image_fill_pointers(VAR_0, VAR_4, VAR_3, buf, VAR_1)) < 0) {
        av_free(buf);
        return VAR_8;
    if (VAR_6->flags & AV_PIX_FMT_FLAG_PAL || VAR_6->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
        avpriv_set_systematic_pal2((uint32_t*)VAR_0[1], VAR_4);
    return VAR_8;
int FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],
int VAR_2, int VAR_3, enum AVPixelFormat VAR_4, int VAR_5)
{ const AVPixFmtDescriptor *VAR_6 = av_pix_fmt_desc_get(VAR_4); int VAR_7, VAR_8; uint8_t *buf; if (!VAR_6)
return AVERROR(EINVAL); if ((VAR_8 = av_image_check_size(VAR_2, VAR_3, 0, NULL)) < 0)
return VAR_8; if ((VAR_8 = av_image_fill_linesizes(VAR_1, VAR_4, VAR_5>7 ? FFALIGN(VAR_2, 8) : VAR_2)) < 0)
return VAR_8; for (VAR_7 = 0; VAR_7 < 4; VAR_7++) VAR_1[VAR_7] = FFALIGN(VAR_1[VAR_7], VAR_5); if ((VAR_8 = av_image_fill_pointers(VAR_0, VAR_4, VAR_3, NULL, VAR_1)) < 0)
return VAR_8; buf = av_malloc(VAR_8 + VAR_5); if (!buf)
return AVERROR(ENOMEM); if ((VAR_8 = av_image_fill_pointers(VAR_0, VAR_4, VAR_3, buf, VAR_1)) < 0) { av_free(buf); return VAR_8; if (VAR_6->flags & AV_PIX_FMT_FLAG_PAL || VAR_6->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
avpriv_set_systematic_pal2((uint32_t*)VAR_0[1], VAR_4); return VAR_8;