static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp)

{

    int i, x, y;

    int depth = (bpp + 1) >> 3;

    int type, count;

    int diff;



    diff = stride - w * depth;

    x = y = 0;

    while(y < h){

        type = *src++;

        count = (type & 0x7F) + 1;

        type &= 0x80;

        if((x + count > w) && (x + count + 1 > (h - y) * w)){

            av_log(avctx, AV_LOG_ERROR, "Packet went out of bounds: position (%i,%i) size %i\n", x, y, count);

            return;

        }

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

            switch(depth){

            case 1:

                *dst = *src;

                break;

            case 2:

                *((uint16_t*)dst) = AV_RL16(src);

                break;

            case 3:

                dst[0] = src[0];

                dst[1] = src[1];

                dst[2] = src[2];

                break;

            case 4:

                *((uint32_t*)dst) = AV_RL32(src);

                break;

            }

            dst += depth;

            if(!type)

                src += depth;



            x++;

            if(x == w){

                x = 0;

                y++;

                dst += diff;

            }

        }

        if(type)

            src += depth;

    }

}

static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp)

{

    int i, x, y;

    int depth = (bpp + 1) >> 3;

    int type, count;

    int diff;



    diff = stride - w * depth;

    x = y = 0;

    while(y < h){

        type = *src++;

        count = (type & 0x7F) + 1;

        type &= 0x80;

        if((x + count > w) && (x + count + 1 > (h - y) * w)){

            av_log(avctx, AV_LOG_ERROR, "Packet went out of bounds: position (%i,%i) size %i\n", x, y, count);

            return;

        }

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

            switch(depth){

            case 1:

                *dst = *src;

                break;

            case 2:

                *((uint16_t*)dst) = AV_RL16(src);

                break;

            case 3:

                dst[0] = src[0];

                dst[1] = src[1];

                dst[2] = src[2];

                break;

            case 4:

                *((uint32_t*)dst) = AV_RL32(src);

                break;

            }

            dst += depth;

            if(!type)

                src += depth;



            x++;

            if(x == w){

                x = 0;

                y++;

                dst += diff;

            }

        }

        if(type)

            src += depth;

    }

}

static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp)
static void FUNC_0(AVCodecContext *VAR_0, TargaContext *VAR_1, const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)

{

    int VAR_8, VAR_9, VAR_10;

    int VAR_11 = (VAR_7 + 1) >> 3;

    int VAR_12, VAR_13;

    int VAR_14;



    VAR_14 = VAR_6 - VAR_4 * VAR_11;

    VAR_9 = VAR_10 = 0;

    while(VAR_10 < VAR_5){

        VAR_12 = *VAR_2++;

        VAR_13 = (VAR_12 & 0x7F) + 1;

        VAR_12 &= 0x80;

        if((VAR_9 + VAR_13 > VAR_4) && (VAR_9 + VAR_13 + 1 > (VAR_5 - VAR_10) * VAR_4)){

            av_log(VAR_0, AV_LOG_ERROR, "Packet went out of bounds: position (%VAR_8,%VAR_8) size %VAR_8\n", VAR_9, VAR_10, VAR_13);

            return;

        }

        for(VAR_8 = 0; VAR_8 < VAR_13; VAR_8++){

            switch(VAR_11){

            case 1:

                *VAR_3 = *VAR_2;

                break;

            case 2:

                *((uint16_t*)VAR_3) = AV_RL16(VAR_2);

                break;

            case 3:

                VAR_3[0] = VAR_2[0];

                VAR_3[1] = VAR_2[1];

                VAR_3[2] = VAR_2[2];

                break;

            case 4:

                *((uint32_t*)VAR_3) = AV_RL32(VAR_2);

                break;

            }

            VAR_3 += VAR_11;

            if(!VAR_12)

                VAR_2 += VAR_11;



            VAR_9++;

            if(VAR_9 == VAR_4){

                VAR_9 = 0;

                VAR_10++;

                VAR_3 += VAR_14;

            }

        }

        if(VAR_12)

            VAR_2 += VAR_11;

    }

}

static void FUNC_0(AVCodecContext *VAR_0, TargaContext *VAR_1, const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)
{ int VAR_8, VAR_9, VAR_10; int VAR_11 = (VAR_7 + 1) >> 3; int VAR_12, VAR_13; int VAR_14; VAR_14 = VAR_6 - VAR_4 * VAR_11; VAR_9 = VAR_10 = 0; while(VAR_10 < VAR_5){ VAR_12 = *VAR_2++; VAR_13 = (VAR_12 & 0x7F) + 1; VAR_12 &= 0x80; if((VAR_9 + VAR_13 > VAR_4) && (VAR_9 + VAR_13 + 1 > (VAR_5 - VAR_10) * VAR_4)){ av_log(VAR_0, AV_LOG_ERROR, "Packet went out of bounds: position (%VAR_8,%VAR_8) size %VAR_8\n", VAR_9, VAR_10, VAR_13); return; } for(VAR_8 = 0; VAR_8 < VAR_13; VAR_8++){ switch(VAR_11){ case 1:
*VAR_3 = *VAR_2; break; case 2:
*((uint16_t*)VAR_3) = AV_RL16(VAR_2); break; case 3:
VAR_3[0] = VAR_2[0]; VAR_3[1] = VAR_2[1]; VAR_3[2] = VAR_2[2]; break; case 4:
*((uint32_t*)VAR_3) = AV_RL32(VAR_2); break; } VAR_3 += VAR_11; if(!VAR_12)
VAR_2 += VAR_11; VAR_9++; if(VAR_9 == VAR_4){ VAR_9 = 0; VAR_10++; VAR_3 += VAR_14; } } if(VAR_12)
VAR_2 += VAR_11; } }