static void save_display_set(DVBSubContext *ctx)

{

    DVBSubRegion *region;

    DVBSubRegionDisplay *display;

    DVBSubCLUT *clut;

    uint32_t *clut_table;

    int x_pos, y_pos, width, height;

    int x, y, y_off, x_off;

    uint32_t *pbuf;

    char filename[32];

    static int fileno_index = 0;



    x_pos = -1;

    y_pos = -1;

    width = 0;

    height = 0;



    for (display = ctx->display_list; display != NULL; display = display->next) {

        region = get_region(ctx, display->region_id);



        if (x_pos == -1) {

            x_pos = display->x_pos;

            y_pos = display->y_pos;

            width = region->width;

            height = region->height;

        } else {

            if (display->x_pos < x_pos) {

                width += (x_pos - display->x_pos);

                x_pos = display->x_pos;

            }



            if (display->y_pos < y_pos) {

                height += (y_pos - display->y_pos);

                y_pos = display->y_pos;

            }



            if (display->x_pos + region->width > x_pos + width) {

                width = display->x_pos + region->width - x_pos;

            }



            if (display->y_pos + region->height > y_pos + height) {

                height = display->y_pos + region->height - y_pos;

            }

        }

    }



    if (x_pos >= 0) {



        pbuf = av_malloc(width * height * 4);



        for (display = ctx->display_list; display != NULL; display = display->next) {

            region = get_region(ctx, display->region_id);



            x_off = display->x_pos - x_pos;

            y_off = display->y_pos - y_pos;



            clut = get_clut(ctx, region->clut);



            if (clut == 0)

                clut = &default_clut;



            switch (region->depth) {

            case 2:

                clut_table = clut->clut4;

                break;

            case 8:

                clut_table = clut->clut256;

                break;

            case 4:

            default:

                clut_table = clut->clut16;

                break;

            }



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

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

                    pbuf[((y + y_off) * width) + x_off + x] =

                        clut_table[region->pbuf[y * region->width + x]];

                }

            }



        }



        snprintf(filename, 32, "dvbs.%d", fileno_index);



        png_save2(filename, pbuf, width, height);



        av_free(pbuf);

    }



    fileno_index++;

}

static void save_display_set(DVBSubContext *ctx)

{

    DVBSubRegion *region;

    DVBSubRegionDisplay *display;

    DVBSubCLUT *clut;

    uint32_t *clut_table;

    int x_pos, y_pos, width, height;

    int x, y, y_off, x_off;

    uint32_t *pbuf;

    char filename[32];

    static int fileno_index = 0;



    x_pos = -1;

    y_pos = -1;

    width = 0;

    height = 0;



    for (display = ctx->display_list; display != NULL; display = display->next) {

        region = get_region(ctx, display->region_id);



        if (x_pos == -1) {

            x_pos = display->x_pos;

            y_pos = display->y_pos;

            width = region->width;

            height = region->height;

        } else {

            if (display->x_pos < x_pos) {

                width += (x_pos - display->x_pos);

                x_pos = display->x_pos;

            }



            if (display->y_pos < y_pos) {

                height += (y_pos - display->y_pos);

                y_pos = display->y_pos;

            }



            if (display->x_pos + region->width > x_pos + width) {

                width = display->x_pos + region->width - x_pos;

            }



            if (display->y_pos + region->height > y_pos + height) {

                height = display->y_pos + region->height - y_pos;

            }

        }

    }



    if (x_pos >= 0) {



        pbuf = av_malloc(width * height * 4);



        for (display = ctx->display_list; display != NULL; display = display->next) {

            region = get_region(ctx, display->region_id);



            x_off = display->x_pos - x_pos;

            y_off = display->y_pos - y_pos;



            clut = get_clut(ctx, region->clut);



            if (clut == 0)

                clut = &default_clut;



            switch (region->depth) {

            case 2:

                clut_table = clut->clut4;

                break;

            case 8:

                clut_table = clut->clut256;

                break;

            case 4:

            default:

                clut_table = clut->clut16;

                break;

            }



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

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

                    pbuf[((y + y_off) * width) + x_off + x] =

                        clut_table[region->pbuf[y * region->width + x]];

                }

            }



        }



        snprintf(filename, 32, "dvbs.%d", fileno_index);



        png_save2(filename, pbuf, width, height);



        av_free(pbuf);

    }



    fileno_index++;

}

static void FUNC_0(DVBSubContext *VAR_0)

{

    DVBSubRegion *region;

    DVBSubRegionDisplay *display;

    DVBSubCLUT *clut;

    uint32_t *clut_table;

    int VAR_1, VAR_2, VAR_3, VAR_4;

    int VAR_5, VAR_6, VAR_7, VAR_8;

    uint32_t *pbuf;

    char VAR_9[32];

    static int VAR_10 = 0;



    VAR_1 = -1;

    VAR_2 = -1;

    VAR_3 = 0;

    VAR_4 = 0;



    for (display = VAR_0->display_list; display != NULL; display = display->next) {

        region = get_region(VAR_0, display->region_id);



        if (VAR_1 == -1) {

            VAR_1 = display->VAR_1;

            VAR_2 = display->VAR_2;

            VAR_3 = region->VAR_3;

            VAR_4 = region->VAR_4;

        } else {

            if (display->VAR_1 < VAR_1) {

                VAR_3 += (VAR_1 - display->VAR_1);

                VAR_1 = display->VAR_1;

            }



            if (display->VAR_2 < VAR_2) {

                VAR_4 += (VAR_2 - display->VAR_2);

                VAR_2 = display->VAR_2;

            }



            if (display->VAR_1 + region->VAR_3 > VAR_1 + VAR_3) {

                VAR_3 = display->VAR_1 + region->VAR_3 - VAR_1;

            }



            if (display->VAR_2 + region->VAR_4 > VAR_2 + VAR_4) {

                VAR_4 = display->VAR_2 + region->VAR_4 - VAR_2;

            }

        }

    }



    if (VAR_1 >= 0) {



        pbuf = av_malloc(VAR_3 * VAR_4 * 4);



        for (display = VAR_0->display_list; display != NULL; display = display->next) {

            region = get_region(VAR_0, display->region_id);



            VAR_8 = display->VAR_1 - VAR_1;

            VAR_7 = display->VAR_2 - VAR_2;



            clut = get_clut(VAR_0, region->clut);



            if (clut == 0)

                clut = &default_clut;



            switch (region->depth) {

            case 2:

                clut_table = clut->clut4;

                break;

            case 8:

                clut_table = clut->clut256;

                break;

            case 4:

            default:

                clut_table = clut->clut16;

                break;

            }



            for (VAR_6 = 0; VAR_6 < region->VAR_4; VAR_6++) {

                for (VAR_5 = 0; VAR_5 < region->VAR_3; VAR_5++) {

                    pbuf[((VAR_6 + VAR_7) * VAR_3) + VAR_8 + VAR_5] =

                        clut_table[region->pbuf[VAR_6 * region->VAR_3 + VAR_5]];

                }

            }



        }



        snprintf(VAR_9, 32, "dvbs.%d", VAR_10);



        png_save2(VAR_9, pbuf, VAR_3, VAR_4);



        av_free(pbuf);

    }



    VAR_10++;

}

static void FUNC_0(DVBSubContext *VAR_0)
{ DVBSubRegion *region; DVBSubRegionDisplay *display; DVBSubCLUT *clut; uint32_t *clut_table; int VAR_1, VAR_2, VAR_3, VAR_4; int VAR_5, VAR_6, VAR_7, VAR_8; uint32_t *pbuf; char VAR_9[32]; static int VAR_10 = 0; VAR_1 = -1; VAR_2 = -1; VAR_3 = 0; VAR_4 = 0; for (display = VAR_0->display_list; display != NULL; display = display->next) { region = get_region(VAR_0, display->region_id); if (VAR_1 == -1) { VAR_1 = display->VAR_1; VAR_2 = display->VAR_2; VAR_3 = region->VAR_3; VAR_4 = region->VAR_4; } else { if (display->VAR_1 < VAR_1) { VAR_3 += (VAR_1 - display->VAR_1); VAR_1 = display->VAR_1; } if (display->VAR_2 < VAR_2) { VAR_4 += (VAR_2 - display->VAR_2); VAR_2 = display->VAR_2; } if (display->VAR_1 + region->VAR_3 > VAR_1 + VAR_3) { VAR_3 = display->VAR_1 + region->VAR_3 - VAR_1; } if (display->VAR_2 + region->VAR_4 > VAR_2 + VAR_4) { VAR_4 = display->VAR_2 + region->VAR_4 - VAR_2; } } } if (VAR_1 >= 0) { pbuf = av_malloc(VAR_3 * VAR_4 * 4); for (display = VAR_0->display_list; display != NULL; display = display->next) { region = get_region(VAR_0, display->region_id); VAR_8 = display->VAR_1 - VAR_1; VAR_7 = display->VAR_2 - VAR_2; clut = get_clut(VAR_0, region->clut); if (clut == 0)
clut = &default_clut; switch (region->depth) { case 2:
clut_table = clut->clut4; break; case 8:
clut_table = clut->clut256; break; case 4:
default:
clut_table = clut->clut16; break; } for (VAR_6 = 0; VAR_6 < region->VAR_4; VAR_6++) { for (VAR_5 = 0; VAR_5 < region->VAR_3; VAR_5++) { pbuf[((VAR_6 + VAR_7) * VAR_3) + VAR_8 + VAR_5] =
clut_table[region->pbuf[VAR_6 * region->VAR_3 + VAR_5]]; } } } snprintf(VAR_9, 32, "dvbs.%d", VAR_10); png_save2(VAR_9, pbuf, VAR_3, VAR_4); av_free(pbuf); } VAR_10++; }