static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])

{

    int x, y, p;

    TYPE *sample[4][2];

    int lbd    = s->avctx->bits_per_raw_sample <= 8;

    int bits   = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8;

    int offset = 1 << bits;



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

        sample[x][0] = RENAME(s->sample_buffer) +  x * 2      * (w + 6) + 3;

        sample[x][1] = RENAME(s->sample_buffer) + (x * 2 + 1) * (w + 6) + 3;

    }



    s->run_index = 0;



    memset(RENAME(s->sample_buffer), 0, 8 * (w + 6) * sizeof(*RENAME(s->sample_buffer)));



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

        for (p = 0; p < 3 + s->transparency; p++) {

            TYPE *temp = sample[p][0]; // FIXME: try a normal buffer



            sample[p][0] = sample[p][1];

            sample[p][1] = temp;



            sample[p][1][-1]= sample[p][0][0  ];

            sample[p][0][ w]= sample[p][0][w-1];

            if (lbd && s->slice_coding_mode == 0)

                RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9);

            else

                RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1));

        }

        for (x = 0; x < w; x++) {

            int g = sample[0][1][x];

            int b = sample[1][1][x];

            int r = sample[2][1][x];

            int a = sample[3][1][x];



            if (s->slice_coding_mode != 1) {

                b -= offset;

                r -= offset;

                g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2;

                b += g;

                r += g;

            }



            if (lbd)

                *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);

            else if (sizeof(TYPE) == 4) {

                *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = g;

                *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = b;

                *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;

            } else {

                *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;

                *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;

                *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;

            }

        }

    }

}

static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])

{

    int x, y, p;

    TYPE *sample[4][2];

    int lbd    = s->avctx->bits_per_raw_sample <= 8;

    int bits   = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8;

    int offset = 1 << bits;



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

        sample[x][0] = RENAME(s->sample_buffer) +  x * 2      * (w + 6) + 3;

        sample[x][1] = RENAME(s->sample_buffer) + (x * 2 + 1) * (w + 6) + 3;

    }



    s->run_index = 0;



    memset(RENAME(s->sample_buffer), 0, 8 * (w + 6) * sizeof(*RENAME(s->sample_buffer)));



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

        for (p = 0; p < 3 + s->transparency; p++) {

            TYPE *temp = sample[p][0]; 



            sample[p][0] = sample[p][1];

            sample[p][1] = temp;



            sample[p][1][-1]= sample[p][0][0  ];

            sample[p][0][ w]= sample[p][0][w-1];

            if (lbd && s->slice_coding_mode == 0)

                RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9);

            else

                RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1));

        }

        for (x = 0; x < w; x++) {

            int g = sample[0][1][x];

            int b = sample[1][1][x];

            int r = sample[2][1][x];

            int a = sample[3][1][x];



            if (s->slice_coding_mode != 1) {

                b -= offset;

                r -= offset;

                g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2;

                b += g;

                r += g;

            }



            if (lbd)

                *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);

            else if (sizeof(TYPE) == 4) {

                *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = g;

                *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = b;

                *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;

            } else {

                *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;

                *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;

                *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;

            }

        }

    }

}

                *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);
static void FUNC_0(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])

{

    int VAR_0, VAR_1, VAR_2;

    TYPE *sample[4][2];

    int VAR_3    = s->avctx->bits_per_raw_sample <= 8;

    int VAR_4   = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8;

    int VAR_5 = 1 << VAR_4;



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

        sample[VAR_0][0] = FUNC_0(s->sample_buffer) +  VAR_0 * 2      * (w + 6) + 3;

        sample[VAR_0][1] = FUNC_0(s->sample_buffer) + (VAR_0 * 2 + 1) * (w + 6) + 3;

    }



    s->run_index = 0;



    memset(FUNC_0(s->sample_buffer), 0, 8 * (w + 6) * sizeof(*FUNC_0(s->sample_buffer)));



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

        for (VAR_2 = 0; VAR_2 < 3 + s->transparency; VAR_2++) {

            TYPE *temp = sample[VAR_2][0]; 



            sample[VAR_2][0] = sample[VAR_2][1];

            sample[VAR_2][1] = temp;



            sample[VAR_2][1][-1]= sample[VAR_2][0][0  ];

            sample[VAR_2][0][ w]= sample[VAR_2][0][w-1];

            if (VAR_3 && s->slice_coding_mode == 0)

                FUNC_0(decode_line)(s, w, sample[VAR_2], (VAR_2 + 1)/2, 9);

            else

                FUNC_0(decode_line)(s, w, sample[VAR_2], (VAR_2 + 1)/2, VAR_4 + (s->slice_coding_mode != 1));

        }

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

            int g = sample[0][1][VAR_0];

            int b = sample[1][1][VAR_0];

            int r = sample[2][1][VAR_0];

            int a = sample[3][1][VAR_0];



            if (s->slice_coding_mode != 1) {

                b -= VAR_5;

                r -= VAR_5;

                g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2;

                b += g;

                r += g;

            }



            if (VAR_3)

                *((uint32_t*)(src[0] + VAR_0*4 + stride[0]*VAR_1)) = b + (g<<8) + (r<<16) + (a<<24);

            else if (sizeof(TYPE) == 4) {

                *((uint16_t*)(src[0] + VAR_0*2 + stride[0]*VAR_1)) = g;

                *((uint16_t*)(src[1] + VAR_0*2 + stride[1]*VAR_1)) = b;

                *((uint16_t*)(src[2] + VAR_0*2 + stride[2]*VAR_1)) = r;

            } else {

                *((uint16_t*)(src[0] + VAR_0*2 + stride[0]*VAR_1)) = b;

                *((uint16_t*)(src[1] + VAR_0*2 + stride[1]*VAR_1)) = g;

                *((uint16_t*)(src[2] + VAR_0*2 + stride[2]*VAR_1)) = r;

            }

        }

    }

}

static void FUNC_0(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])
{ int VAR_0, VAR_1, VAR_2; TYPE *sample[4][2]; int VAR_3    = s->avctx->bits_per_raw_sample <= 8; int VAR_4   = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8; int VAR_5 = 1 << VAR_4; for (VAR_0 = 0; VAR_0 < 4; VAR_0++) { sample[VAR_0][0] = FUNC_0(s->sample_buffer) +  VAR_0 * 2      * (w + 6) + 3; sample[VAR_0][1] = FUNC_0(s->sample_buffer) + (VAR_0 * 2 + 1) * (w + 6) + 3; } s->run_index = 0; memset(FUNC_0(s->sample_buffer), 0, 8 * (w + 6) * sizeof(*FUNC_0(s->sample_buffer))); for (VAR_1 = 0; VAR_1 < h; VAR_1++) { for (VAR_2 = 0; VAR_2 < 3 + s->transparency; VAR_2++) { TYPE *temp = sample[VAR_2][0]; sample[VAR_2][0] = sample[VAR_2][1]; sample[VAR_2][1] = temp; sample[VAR_2][1][-1]= sample[VAR_2][0][0  ]; sample[VAR_2][0][ w]= sample[VAR_2][0][w-1]; if (VAR_3 && s->slice_coding_mode == 0)
FUNC_0(decode_line)(s, w, sample[VAR_2], (VAR_2 + 1)/2, 9); else
FUNC_0(decode_line)(s, w, sample[VAR_2], (VAR_2 + 1)/2, VAR_4 + (s->slice_coding_mode != 1)); } for (VAR_0 = 0; VAR_0 < w; VAR_0++) { int g = sample[0][1][VAR_0]; int b = sample[1][1][VAR_0]; int r = sample[2][1][VAR_0]; int a = sample[3][1][VAR_0]; if (s->slice_coding_mode != 1) { b -= VAR_5; r -= VAR_5; g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2; b += g; r += g; } if (VAR_3)
*((uint32_t*)(src[0] + VAR_0*4 + stride[0]*VAR_1)) = b + (g<<8) + (r<<16) + (a<<24); else if (sizeof(TYPE) == 4) { *((uint16_t*)(src[0] + VAR_0*2 + stride[0]*VAR_1)) = g; *((uint16_t*)(src[1] + VAR_0*2 + stride[1]*VAR_1)) = b; *((uint16_t*)(src[2] + VAR_0*2 + stride[2]*VAR_1)) = r; } else { *((uint16_t*)(src[0] + VAR_0*2 + stride[0]*VAR_1)) = b; *((uint16_t*)(src[1] + VAR_0*2 + stride[1]*VAR_1)) = g; *((uint16_t*)(src[2] + VAR_0*2 + stride[2]*VAR_1)) = r; } } } }