static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s)

{

    int x, y;

    unsigned char P[4];

    int flags = 0;



    /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on

     * either top and bottom or left and right halves */

    CHECK_STREAM_PTR(24);



    if (s->stream_ptr[0] <= s->stream_ptr[1]) {



        /* 4-color encoding for each quadrant; need 32 bytes */

        CHECK_STREAM_PTR(32);



        for (y = 0; y < 16; y++) {

            // new values for each 4x4 block

            if (!(y & 3)) {

                memcpy(P, s->stream_ptr, 4);

                s->stream_ptr += 4;

                flags = bytestream_get_le32(&s->stream_ptr);

            }



            for (x = 0; x < 4; x++, flags >>= 2)

                *s->pixel_ptr++ = P[flags & 0x03];



            s->pixel_ptr += s->stride - 4;

            // switch to right half

            if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;

        }



    } else {

        // vertical split?

        int vert = s->stream_ptr[12] <= s->stream_ptr[13];

        uint64_t flags = 0;



        /* 4-color encoding for either left and right or top and bottom

         * halves */



        for (y = 0; y < 16; y++) {

            // load values for each half

            if (!(y & 7)) {

                memcpy(P, s->stream_ptr, 4);

                s->stream_ptr += 4;

                flags = bytestream_get_le64(&s->stream_ptr);

            }



            for (x = 0; x < 4; x++, flags >>= 2)

                *s->pixel_ptr++ = P[flags & 0x03];



            if (vert) {

                s->pixel_ptr += s->stride - 4;

                // switch to right half

                if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;

            } else if (y & 1) s->pixel_ptr += s->line_inc;

        }

    }



    /* report success */

    return 0;

}

static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s)

{

    int x, y;

    unsigned char P[4];

    int flags = 0;



    



    CHECK_STREAM_PTR(24);



    if (s->stream_ptr[0] <= s->stream_ptr[1]) {



        

        CHECK_STREAM_PTR(32);



        for (y = 0; y < 16; y++) {

            

            if (!(y & 3)) {

                memcpy(P, s->stream_ptr, 4);

                s->stream_ptr += 4;

                flags = bytestream_get_le32(&s->stream_ptr);

            }



            for (x = 0; x < 4; x++, flags >>= 2)

                *s->pixel_ptr++ = P[flags & 0x03];



            s->pixel_ptr += s->stride - 4;

            

            if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;

        }



    } else {

        

        int vert = s->stream_ptr[12] <= s->stream_ptr[13];

        uint64_t flags = 0;



        





        for (y = 0; y < 16; y++) {

            

            if (!(y & 7)) {

                memcpy(P, s->stream_ptr, 4);

                s->stream_ptr += 4;

                flags = bytestream_get_le64(&s->stream_ptr);

            }



            for (x = 0; x < 4; x++, flags >>= 2)

                *s->pixel_ptr++ = P[flags & 0x03];



            if (vert) {

                s->pixel_ptr += s->stride - 4;

                

                if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;

            } else if (y & 1) s->pixel_ptr += s->line_inc;

        }

    }



    

    return 0;

}

static int FUNC_0(IpvideoContext *VAR_0)

{

    int VAR_1, VAR_2;

    unsigned char VAR_3[4];

    int VAR_4 = 0;



    



    CHECK_STREAM_PTR(24);



    if (VAR_0->stream_ptr[0] <= VAR_0->stream_ptr[1]) {



        

        CHECK_STREAM_PTR(32);



        for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {

            

            if (!(VAR_2 & 3)) {

                memcpy(VAR_3, VAR_0->stream_ptr, 4);

                VAR_0->stream_ptr += 4;

                VAR_4 = bytestream_get_le32(&VAR_0->stream_ptr);

            }



            for (VAR_1 = 0; VAR_1 < 4; VAR_1++, VAR_4 >>= 2)

                *VAR_0->pixel_ptr++ = VAR_3[VAR_4 & 0x03];



            VAR_0->pixel_ptr += VAR_0->stride - 4;

            

            if (VAR_2 == 7) VAR_0->pixel_ptr -= 8 * VAR_0->stride - 4;

        }



    } else {

        

        int VAR_5 = VAR_0->stream_ptr[12] <= VAR_0->stream_ptr[13];

        uint64_t VAR_4 = 0;



        





        for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {

            

            if (!(VAR_2 & 7)) {

                memcpy(VAR_3, VAR_0->stream_ptr, 4);

                VAR_0->stream_ptr += 4;

                VAR_4 = bytestream_get_le64(&VAR_0->stream_ptr);

            }



            for (VAR_1 = 0; VAR_1 < 4; VAR_1++, VAR_4 >>= 2)

                *VAR_0->pixel_ptr++ = VAR_3[VAR_4 & 0x03];



            if (VAR_5) {

                VAR_0->pixel_ptr += VAR_0->stride - 4;

                

                if (VAR_2 == 7) VAR_0->pixel_ptr -= 8 * VAR_0->stride - 4;

            } else if (VAR_2 & 1) VAR_0->pixel_ptr += VAR_0->line_inc;

        }

    }



    

    return 0;

}

static int FUNC_0(IpvideoContext *VAR_0)
{ int VAR_1, VAR_2; unsigned char VAR_3[4]; int VAR_4 = 0; CHECK_STREAM_PTR(24); if (VAR_0->stream_ptr[0] <= VAR_0->stream_ptr[1]) { CHECK_STREAM_PTR(32); for (VAR_2 = 0; VAR_2 < 16; VAR_2++) { if (!(VAR_2 & 3)) { memcpy(VAR_3, VAR_0->stream_ptr, 4); VAR_0->stream_ptr += 4; VAR_4 = bytestream_get_le32(&VAR_0->stream_ptr); } for (VAR_1 = 0; VAR_1 < 4; VAR_1++, VAR_4 >>= 2) *VAR_0->pixel_ptr++ = VAR_3[VAR_4 & 0x03]; VAR_0->pixel_ptr += VAR_0->stride - 4; if (VAR_2 == 7) VAR_0->pixel_ptr -= 8 * VAR_0->stride - 4; } } else { int VAR_5 = VAR_0->stream_ptr[12] <= VAR_0->stream_ptr[13]; uint64_t VAR_4 = 0; for (VAR_2 = 0; VAR_2 < 16; VAR_2++) { if (!(VAR_2 & 7)) { memcpy(VAR_3, VAR_0->stream_ptr, 4); VAR_0->stream_ptr += 4; VAR_4 = bytestream_get_le64(&VAR_0->stream_ptr); } for (VAR_1 = 0; VAR_1 < 4; VAR_1++, VAR_4 >>= 2) *VAR_0->pixel_ptr++ = VAR_3[VAR_4 & 0x03]; if (VAR_5) { VAR_0->pixel_ptr += VAR_0->stride - 4; if (VAR_2 == 7) VAR_0->pixel_ptr -= 8 * VAR_0->stride - 4; } else if (VAR_2 & 1) VAR_0->pixel_ptr += VAR_0->line_inc; } } return 0; }