static int apply_color_indexing_transform(WebPContext *s)

{

    ImageContext *img;

    ImageContext *pal;

    int i, x, y;

    uint8_t *p, *pi;



    img = &s->image[IMAGE_ROLE_ARGB];

    pal = &s->image[IMAGE_ROLE_COLOR_INDEXING];



    if (pal->size_reduction > 0) {

        GetBitContext gb_g;

        uint8_t *line;

        int pixel_bits = 8 >> pal->size_reduction;



        line = av_malloc(img->frame->linesize[0]);

        if (!line)

            return AVERROR(ENOMEM);



        for (y = 0; y < img->frame->height; y++) {

            p = GET_PIXEL(img->frame, 0, y);

            memcpy(line, p, img->frame->linesize[0]);

            init_get_bits(&gb_g, line, img->frame->linesize[0] * 8);

            skip_bits(&gb_g, 16);

            i = 0;

            for (x = 0; x < img->frame->width; x++) {

                p    = GET_PIXEL(img->frame, x, y);

                p[2] = get_bits(&gb_g, pixel_bits);

                i++;

                if (i == 1 << pal->size_reduction) {

                    skip_bits(&gb_g, 24);

                    i = 0;

                }

            }

        }

        av_free(line);

    }



    for (y = 0; y < img->frame->height; y++) {

        for (x = 0; x < img->frame->width; x++) {

            p = GET_PIXEL(img->frame, x, y);

            i = p[2];

            if (i >= pal->frame->width) {

                av_log(s->avctx, AV_LOG_ERROR, "invalid palette index %d\n", i);

                return AVERROR_INVALIDDATA;

            }

            pi = GET_PIXEL(pal->frame, i, 0);

            AV_COPY32(p, pi);

        }

    }



    return 0;

}

static int apply_color_indexing_transform(WebPContext *s)

{

    ImageContext *img;

    ImageContext *pal;

    int i, x, y;

    uint8_t *p, *pi;



    img = &s->image[IMAGE_ROLE_ARGB];

    pal = &s->image[IMAGE_ROLE_COLOR_INDEXING];



    if (pal->size_reduction > 0) {

        GetBitContext gb_g;

        uint8_t *line;

        int pixel_bits = 8 >> pal->size_reduction;



        line = av_malloc(img->frame->linesize[0]);

        if (!line)

            return AVERROR(ENOMEM);



        for (y = 0; y < img->frame->height; y++) {

            p = GET_PIXEL(img->frame, 0, y);

            memcpy(line, p, img->frame->linesize[0]);

            init_get_bits(&gb_g, line, img->frame->linesize[0] * 8);

            skip_bits(&gb_g, 16);

            i = 0;

            for (x = 0; x < img->frame->width; x++) {

                p    = GET_PIXEL(img->frame, x, y);

                p[2] = get_bits(&gb_g, pixel_bits);

                i++;

                if (i == 1 << pal->size_reduction) {

                    skip_bits(&gb_g, 24);

                    i = 0;

                }

            }

        }

        av_free(line);

    }



    for (y = 0; y < img->frame->height; y++) {

        for (x = 0; x < img->frame->width; x++) {

            p = GET_PIXEL(img->frame, x, y);

            i = p[2];

            if (i >= pal->frame->width) {

                av_log(s->avctx, AV_LOG_ERROR, "invalid palette index %d\n", i);

                return AVERROR_INVALIDDATA;

            }

            pi = GET_PIXEL(pal->frame, i, 0);

            AV_COPY32(p, pi);

        }

    }



    return 0;

}

    uint8_t *p, *pi;                 av_log(s->avctx, AV_LOG_ERROR, "invalid palette index %d\n", i);                 return AVERROR_INVALIDDATA;             pi = GET_PIXEL(pal->frame, i, 0);             AV_COPY32(p, pi);
static int FUNC_0(WebPContext *VAR_0)

{

    ImageContext *img;

    ImageContext *pal;

    int VAR_1, VAR_2, VAR_3;

    uint8_t *p, *pi;



    img = &VAR_0->image[IMAGE_ROLE_ARGB];

    pal = &VAR_0->image[IMAGE_ROLE_COLOR_INDEXING];



    if (pal->size_reduction > 0) {

        GetBitContext gb_g;

        uint8_t *line;

        int VAR_4 = 8 >> pal->size_reduction;



        line = av_malloc(img->frame->linesize[0]);

        if (!line)

            return AVERROR(ENOMEM);



        for (VAR_3 = 0; VAR_3 < img->frame->height; VAR_3++) {

            p = GET_PIXEL(img->frame, 0, VAR_3);

            memcpy(line, p, img->frame->linesize[0]);

            init_get_bits(&gb_g, line, img->frame->linesize[0] * 8);

            skip_bits(&gb_g, 16);

            VAR_1 = 0;

            for (VAR_2 = 0; VAR_2 < img->frame->width; VAR_2++) {

                p    = GET_PIXEL(img->frame, VAR_2, VAR_3);

                p[2] = get_bits(&gb_g, VAR_4);

                VAR_1++;

                if (VAR_1 == 1 << pal->size_reduction) {

                    skip_bits(&gb_g, 24);

                    VAR_1 = 0;

                }

            }

        }

        av_free(line);

    }



    for (VAR_3 = 0; VAR_3 < img->frame->height; VAR_3++) {

        for (VAR_2 = 0; VAR_2 < img->frame->width; VAR_2++) {

            p = GET_PIXEL(img->frame, VAR_2, VAR_3);

            VAR_1 = p[2];

            if (VAR_1 >= pal->frame->width) {

                av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid palette index %d\n", VAR_1);

                return AVERROR_INVALIDDATA;

            }

            pi = GET_PIXEL(pal->frame, VAR_1, 0);

            AV_COPY32(p, pi);

        }

    }



    return 0;

}

static int FUNC_0(WebPContext *VAR_0)
{ ImageContext *img; ImageContext *pal; int VAR_1, VAR_2, VAR_3; uint8_t *p, *pi; img = &VAR_0->image[IMAGE_ROLE_ARGB]; pal = &VAR_0->image[IMAGE_ROLE_COLOR_INDEXING]; if (pal->size_reduction > 0) { GetBitContext gb_g; uint8_t *line; int VAR_4 = 8 >> pal->size_reduction; line = av_malloc(img->frame->linesize[0]); if (!line)
return AVERROR(ENOMEM); for (VAR_3 = 0; VAR_3 < img->frame->height; VAR_3++) { p = GET_PIXEL(img->frame, 0, VAR_3); memcpy(line, p, img->frame->linesize[0]); init_get_bits(&gb_g, line, img->frame->linesize[0] * 8); skip_bits(&gb_g, 16); VAR_1 = 0; for (VAR_2 = 0; VAR_2 < img->frame->width; VAR_2++) { p    = GET_PIXEL(img->frame, VAR_2, VAR_3); p[2] = get_bits(&gb_g, VAR_4); VAR_1++; if (VAR_1 == 1 << pal->size_reduction) { skip_bits(&gb_g, 24); VAR_1 = 0; } } } av_free(line); } for (VAR_3 = 0; VAR_3 < img->frame->height; VAR_3++) { for (VAR_2 = 0; VAR_2 < img->frame->width; VAR_2++) { p = GET_PIXEL(img->frame, VAR_2, VAR_3); VAR_1 = p[2]; if (VAR_1 >= pal->frame->width) { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid palette index %d\n", VAR_1); return AVERROR_INVALIDDATA; } pi = GET_PIXEL(pal->frame, VAR_1, 0); AV_COPY32(p, pi); } } return 0; }