static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth,

                                 unsigned size)

{

    unsigned i, j;

    CodeBook cb = { 0 };



    if (!can_safely_read(gb, (uint64_t)size * 34))

        return cb;



    if (size >= INT_MAX / sizeof(MacroBlock))

        return cb;

    cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1);

    if (!cb.blocks)

        return cb;



    cb.depth = depth;

    cb.size = size;

    for (i = 0; i < size; i++) {

        unsigned mask_bits = get_bits(gb, 4);

        unsigned color0 = get_bits(gb, 15);

        unsigned color1 = get_bits(gb, 15);



        for (j = 0; j < 4; j++) {

            if (mask_bits & (1 << j))

                cb.blocks[i].pixels[j] = color1;

            else

                cb.blocks[i].pixels[j] = color0;

        }

    }

    return cb;

}

static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth,

                                 unsigned size)

{

    unsigned i, j;

    CodeBook cb = { 0 };



    if (!can_safely_read(gb, (uint64_t)size * 34))

        return cb;



    if (size >= INT_MAX / sizeof(MacroBlock))

        return cb;

    cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1);

    if (!cb.blocks)

        return cb;



    cb.depth = depth;

    cb.size = size;

    for (i = 0; i < size; i++) {

        unsigned mask_bits = get_bits(gb, 4);

        unsigned color0 = get_bits(gb, 15);

        unsigned color1 = get_bits(gb, 15);



        for (j = 0; j < 4; j++) {

            if (mask_bits & (1 << j))

                cb.blocks[i].pixels[j] = color1;

            else

                cb.blocks[i].pixels[j] = color0;

        }

    }

    return cb;

}

static CodeBook FUNC_0(GetBitContext* gb, unsigned depth,

                                 unsigned size)

{

    unsigned VAR_0, VAR_1;

    CodeBook cb = { 0 };



    if (!can_safely_read(gb, (uint64_t)size * 34))

        return cb;



    if (size >= INT_MAX / sizeof(MacroBlock))

        return cb;

    cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1);

    if (!cb.blocks)

        return cb;



    cb.depth = depth;

    cb.size = size;

    for (VAR_0 = 0; VAR_0 < size; VAR_0++) {

        unsigned VAR_2 = get_bits(gb, 4);

        unsigned VAR_3 = get_bits(gb, 15);

        unsigned VAR_4 = get_bits(gb, 15);



        for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {

            if (VAR_2 & (1 << VAR_1))

                cb.blocks[VAR_0].pixels[VAR_1] = VAR_4;

            else

                cb.blocks[VAR_0].pixels[VAR_1] = VAR_3;

        }

    }

    return cb;

}

static CodeBook FUNC_0(GetBitContext* gb, unsigned depth,
unsigned size)
{ unsigned VAR_0, VAR_1; CodeBook cb = { 0 }; if (!can_safely_read(gb, (uint64_t)size * 34))
return cb; if (size >= INT_MAX / sizeof(MacroBlock))
return cb; cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1); if (!cb.blocks)
return cb; cb.depth = depth; cb.size = size; for (VAR_0 = 0; VAR_0 < size; VAR_0++) { unsigned VAR_2 = get_bits(gb, 4); unsigned VAR_3 = get_bits(gb, 15); unsigned VAR_4 = get_bits(gb, 15); for (VAR_1 = 0; VAR_1 < 4; VAR_1++) { if (VAR_2 & (1 << VAR_1))
cb.blocks[VAR_0].pixels[VAR_1] = VAR_4; else
cb.blocks[VAR_0].pixels[VAR_1] = VAR_3; } } return cb; }