static void truemotion1_decode_16bit(TrueMotion1Context *s)

{

    int y;

    int pixels_left;  /* remaining pixels on this line */

    unsigned int predictor_pair;

    unsigned int horiz_pred;

    unsigned int *vert_pred;

    unsigned int *current_pixel_pair;

    unsigned char *current_line = s->frame->data[0];

    int keyframe = s->flags & FLAG_KEYFRAME;



    /* these variables are for managing the stream of macroblock change bits */

    const unsigned char *mb_change_bits = s->mb_change_bits;

    unsigned char mb_change_byte;

    unsigned char mb_change_byte_mask;

    int mb_change_index;



    /* these variables are for managing the main index stream */

    int index_stream_index = 0;  /* yes, the index into the index stream */

    int index;



    /* clean out the line buffer */

    memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int));



    GET_NEXT_INDEX();



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



        /* re-init variables for the next line iteration */

        horiz_pred = 0;

        current_pixel_pair = (unsigned int *)current_line;

        vert_pred = s->vert_pred;

        mb_change_index = 0;

        mb_change_byte = mb_change_bits[mb_change_index++];

        mb_change_byte_mask = 0x01;

        pixels_left = s->avctx->width;



        while (pixels_left > 0) {



            if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {



                switch (y & 3) {

                case 0:

                    /* if macroblock width is 2, apply C-Y-C-Y; else

                     * apply C-Y-Y */

                    if (s->block_width == 2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    }

                    break;



                case 1:

                case 3:

                    /* always apply 2 Y predictors on these iterations */

                    APPLY_Y_PREDICTOR();

                    OUTPUT_PIXEL_PAIR();

                    APPLY_Y_PREDICTOR();

                    OUTPUT_PIXEL_PAIR();

                    break;



                case 2:

                    /* this iteration might be C-Y-C-Y, Y-Y, or C-Y-Y

                     * depending on the macroblock type */

                    if (s->block_type == BLOCK_2x2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else if (s->block_type == BLOCK_4x2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else {

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    }

                    break;

                }



            } else {



                /* skip (copy) four pixels, but reassign the horizontal

                 * predictor */

                *vert_pred++ = *current_pixel_pair++;

                horiz_pred = *current_pixel_pair - *vert_pred;

                *vert_pred++ = *current_pixel_pair++;



            }



            if (!keyframe) {

                mb_change_byte_mask <<= 1;



                /* next byte */

                if (!mb_change_byte_mask) {

                    mb_change_byte = mb_change_bits[mb_change_index++];

                    mb_change_byte_mask = 0x01;

                }

            }



            pixels_left -= 4;

        }



        /* next change row */

        if (((y + 1) & 3) == 0)

            mb_change_bits += s->mb_change_bits_row_size;



        current_line += s->frame->linesize[0];

    }

}

static void truemotion1_decode_16bit(TrueMotion1Context *s)

{

    int y;

    int pixels_left;  

    unsigned int predictor_pair;

    unsigned int horiz_pred;

    unsigned int *vert_pred;

    unsigned int *current_pixel_pair;

    unsigned char *current_line = s->frame->data[0];

    int keyframe = s->flags & FLAG_KEYFRAME;



    

    const unsigned char *mb_change_bits = s->mb_change_bits;

    unsigned char mb_change_byte;

    unsigned char mb_change_byte_mask;

    int mb_change_index;



    

    int index_stream_index = 0;  

    int index;



    

    memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int));



    GET_NEXT_INDEX();



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



        

        horiz_pred = 0;

        current_pixel_pair = (unsigned int *)current_line;

        vert_pred = s->vert_pred;

        mb_change_index = 0;

        mb_change_byte = mb_change_bits[mb_change_index++];

        mb_change_byte_mask = 0x01;

        pixels_left = s->avctx->width;



        while (pixels_left > 0) {



            if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) {



                switch (y & 3) {

                case 0:

                    



                    if (s->block_width == 2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    }

                    break;



                case 1:

                case 3:

                    

                    APPLY_Y_PREDICTOR();

                    OUTPUT_PIXEL_PAIR();

                    APPLY_Y_PREDICTOR();

                    OUTPUT_PIXEL_PAIR();

                    break;



                case 2:

                    



                    if (s->block_type == BLOCK_2x2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else if (s->block_type == BLOCK_4x2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else {

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    }

                    break;

                }



            } else {



                



                *vert_pred++ = *current_pixel_pair++;

                horiz_pred = *current_pixel_pair - *vert_pred;

                *vert_pred++ = *current_pixel_pair++;



            }



            if (!keyframe) {

                mb_change_byte_mask <<= 1;



                

                if (!mb_change_byte_mask) {

                    mb_change_byte = mb_change_bits[mb_change_index++];

                    mb_change_byte_mask = 0x01;

                }

            }



            pixels_left -= 4;

        }



        

        if (((y + 1) & 3) == 0)

            mb_change_bits += s->mb_change_bits_row_size;



        current_line += s->frame->linesize[0];

    }

}

static void FUNC_0(TrueMotion1Context *VAR_0)

{

    int VAR_1;

    int VAR_2;  

    unsigned int VAR_3;

    unsigned int VAR_4;

    unsigned int *VAR_5;

    unsigned int *VAR_6;

    unsigned char *VAR_7 = VAR_0->frame->data[0];

    int VAR_8 = VAR_0->flags & FLAG_KEYFRAME;



    

    const unsigned char *VAR_9 = VAR_0->VAR_9;

    unsigned char VAR_10;

    unsigned char VAR_11;

    int VAR_12;



    

    int VAR_13 = 0;  

    int VAR_14;



    

    memset(VAR_0->VAR_5, 0, VAR_0->avctx->width * sizeof(unsigned int));



    GET_NEXT_INDEX();



    for (VAR_1 = 0; VAR_1 < VAR_0->avctx->height; VAR_1++) {



        

        VAR_4 = 0;

        VAR_6 = (unsigned int *)VAR_7;

        VAR_5 = VAR_0->VAR_5;

        VAR_12 = 0;

        VAR_10 = VAR_9[VAR_12++];

        VAR_11 = 0x01;

        VAR_2 = VAR_0->avctx->width;



        while (VAR_2 > 0) {



            if (VAR_8 || ((VAR_10 & VAR_11) == 0)) {



                switch (VAR_1 & 3) {

                case 0:

                    



                    if (VAR_0->block_width == 2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    }

                    break;



                case 1:

                case 3:

                    

                    APPLY_Y_PREDICTOR();

                    OUTPUT_PIXEL_PAIR();

                    APPLY_Y_PREDICTOR();

                    OUTPUT_PIXEL_PAIR();

                    break;



                case 2:

                    



                    if (VAR_0->block_type == BLOCK_2x2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else if (VAR_0->block_type == BLOCK_4x2) {

                        APPLY_C_PREDICTOR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    } else {

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                        APPLY_Y_PREDICTOR();

                        OUTPUT_PIXEL_PAIR();

                    }

                    break;

                }



            } else {



                



                *VAR_5++ = *VAR_6++;

                VAR_4 = *VAR_6 - *VAR_5;

                *VAR_5++ = *VAR_6++;



            }



            if (!VAR_8) {

                VAR_11 <<= 1;



                

                if (!VAR_11) {

                    VAR_10 = VAR_9[VAR_12++];

                    VAR_11 = 0x01;

                }

            }



            VAR_2 -= 4;

        }



        

        if (((VAR_1 + 1) & 3) == 0)

            VAR_9 += VAR_0->mb_change_bits_row_size;



        VAR_7 += VAR_0->frame->linesize[0];

    }

}

static void FUNC_0(TrueMotion1Context *VAR_0)
{ int VAR_1; int VAR_2; unsigned int VAR_3; unsigned int VAR_4; unsigned int *VAR_5; unsigned int *VAR_6; unsigned char *VAR_7 = VAR_0->frame->data[0]; int VAR_8 = VAR_0->flags & FLAG_KEYFRAME; const unsigned char *VAR_9 = VAR_0->VAR_9; unsigned char VAR_10; unsigned char VAR_11; int VAR_12; int VAR_13 = 0; int VAR_14; memset(VAR_0->VAR_5, 0, VAR_0->avctx->width * sizeof(unsigned int)); GET_NEXT_INDEX(); for (VAR_1 = 0; VAR_1 < VAR_0->avctx->height; VAR_1++) { VAR_4 = 0; VAR_6 = (unsigned int *)VAR_7; VAR_5 = VAR_0->VAR_5; VAR_12 = 0; VAR_10 = VAR_9[VAR_12++]; VAR_11 = 0x01; VAR_2 = VAR_0->avctx->width; while (VAR_2 > 0) { if (VAR_8 || ((VAR_10 & VAR_11) == 0)) { switch (VAR_1 & 3) { case 0:
if (VAR_0->block_width == 2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } break; case 1:
case 3:
APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); break; case 2:
if (VAR_0->block_type == BLOCK_2x2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else if (VAR_0->block_type == BLOCK_4x2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else { APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } break; } } else { *VAR_5++ = *VAR_6++; VAR_4 = *VAR_6 - *VAR_5; *VAR_5++ = *VAR_6++; } if (!VAR_8) { VAR_11 <<= 1; if (!VAR_11) { VAR_10 = VAR_9[VAR_12++]; VAR_11 = 0x01; } } VAR_2 -= 4; } if (((VAR_1 + 1) & 3) == 0)
VAR_9 += VAR_0->mb_change_bits_row_size; VAR_7 += VAR_0->frame->linesize[0]; } }