int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)

{

    int64_t crv =  inv_table[0];

    int64_t cbu =  inv_table[1];

    int64_t cgu = -inv_table[2];

    int64_t cgv = -inv_table[3];

    int64_t cy  = 1<<16;

    int64_t oy  = 0;



    memcpy(c->srcColorspaceTable, inv_table, sizeof(int)*4);

    memcpy(c->dstColorspaceTable,     table, sizeof(int)*4);



    c->brightness= brightness;

    c->contrast  = contrast;

    c->saturation= saturation;

    c->srcRange  = srcRange;

    c->dstRange  = dstRange;

    if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1;



    c->uOffset=   0x0400040004000400LL;

    c->vOffset=   0x0400040004000400LL;



    if (!srcRange) {

        cy= (cy*255) / 219;

        oy= 16<<16;

    } else {

        crv= (crv*224) / 255;

        cbu= (cbu*224) / 255;

        cgu= (cgu*224) / 255;

        cgv= (cgv*224) / 255;

    }



    cy = (cy *contrast             )>>16;

    crv= (crv*contrast * saturation)>>32;

    cbu= (cbu*contrast * saturation)>>32;

    cgu= (cgu*contrast * saturation)>>32;

    cgv= (cgv*contrast * saturation)>>32;



    oy -= 256*brightness;



    c->yCoeff=    roundToInt16(cy *8192) * 0x0001000100010001ULL;

    c->vrCoeff=   roundToInt16(crv*8192) * 0x0001000100010001ULL;

    c->ubCoeff=   roundToInt16(cbu*8192) * 0x0001000100010001ULL;

    c->vgCoeff=   roundToInt16(cgv*8192) * 0x0001000100010001ULL;

    c->ugCoeff=   roundToInt16(cgu*8192) * 0x0001000100010001ULL;

    c->yOffset=   roundToInt16(oy *   8) * 0x0001000100010001ULL;



    c->yuv2rgb_y_coeff  = (int16_t)roundToInt16(cy <<13);

    c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);

    c->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13);

    c->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13);

    c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);

    c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);



    ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation);

    //FIXME factorize



#if ARCH_PPC && HAVE_ALTIVEC

    if (c->flags & SWS_CPU_CAPS_ALTIVEC)

        ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness, contrast, saturation);

#endif

    return 0;

}

int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)

{

    int64_t crv =  inv_table[0];

    int64_t cbu =  inv_table[1];

    int64_t cgu = -inv_table[2];

    int64_t cgv = -inv_table[3];

    int64_t cy  = 1<<16;

    int64_t oy  = 0;



    memcpy(c->srcColorspaceTable, inv_table, sizeof(int)*4);

    memcpy(c->dstColorspaceTable,     table, sizeof(int)*4);



    c->brightness= brightness;

    c->contrast  = contrast;

    c->saturation= saturation;

    c->srcRange  = srcRange;

    c->dstRange  = dstRange;

    if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1;



    c->uOffset=   0x0400040004000400LL;

    c->vOffset=   0x0400040004000400LL;



    if (!srcRange) {

        cy= (cy*255) / 219;

        oy= 16<<16;

    } else {

        crv= (crv*224) / 255;

        cbu= (cbu*224) / 255;

        cgu= (cgu*224) / 255;

        cgv= (cgv*224) / 255;

    }



    cy = (cy *contrast             )>>16;

    crv= (crv*contrast * saturation)>>32;

    cbu= (cbu*contrast * saturation)>>32;

    cgu= (cgu*contrast * saturation)>>32;

    cgv= (cgv*contrast * saturation)>>32;



    oy -= 256*brightness;



    c->yCoeff=    roundToInt16(cy *8192) * 0x0001000100010001ULL;

    c->vrCoeff=   roundToInt16(crv*8192) * 0x0001000100010001ULL;

    c->ubCoeff=   roundToInt16(cbu*8192) * 0x0001000100010001ULL;

    c->vgCoeff=   roundToInt16(cgv*8192) * 0x0001000100010001ULL;

    c->ugCoeff=   roundToInt16(cgu*8192) * 0x0001000100010001ULL;

    c->yOffset=   roundToInt16(oy *   8) * 0x0001000100010001ULL;



    c->yuv2rgb_y_coeff  = (int16_t)roundToInt16(cy <<13);

    c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);

    c->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13);

    c->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13);

    c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);

    c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);



    ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation);

    



#if ARCH_PPC && HAVE_ALTIVEC

    if (c->flags & SWS_CPU_CAPS_ALTIVEC)

        ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness, contrast, saturation);

#endif

    return 0;

}

int FUNC_0(SwsContext *VAR_0, const int VAR_1[4], int VAR_2, const int VAR_3[4], int VAR_4, int VAR_5, int VAR_6, int VAR_7)

{

    int64_t crv =  VAR_1[0];

    int64_t cbu =  VAR_1[1];

    int64_t cgu = -VAR_1[2];

    int64_t cgv = -VAR_1[3];

    int64_t cy  = 1<<16;

    int64_t oy  = 0;



    memcpy(VAR_0->srcColorspaceTable, VAR_1, sizeof(int)*4);

    memcpy(VAR_0->dstColorspaceTable,     VAR_3, sizeof(int)*4);



    VAR_0->VAR_5= VAR_5;

    VAR_0->VAR_6  = VAR_6;

    VAR_0->VAR_7= VAR_7;

    VAR_0->VAR_2  = VAR_2;

    VAR_0->VAR_4  = VAR_4;

    if (isYUV(VAR_0->dstFormat) || isGray(VAR_0->dstFormat)) return -1;



    VAR_0->uOffset=   0x0400040004000400LL;

    VAR_0->vOffset=   0x0400040004000400LL;



    if (!VAR_2) {

        cy= (cy*255) / 219;

        oy= 16<<16;

    } else {

        crv= (crv*224) / 255;

        cbu= (cbu*224) / 255;

        cgu= (cgu*224) / 255;

        cgv= (cgv*224) / 255;

    }



    cy = (cy *VAR_6             )>>16;

    crv= (crv*VAR_6 * VAR_7)>>32;

    cbu= (cbu*VAR_6 * VAR_7)>>32;

    cgu= (cgu*VAR_6 * VAR_7)>>32;

    cgv= (cgv*VAR_6 * VAR_7)>>32;



    oy -= 256*VAR_5;



    VAR_0->yCoeff=    roundToInt16(cy *8192) * 0x0001000100010001ULL;

    VAR_0->vrCoeff=   roundToInt16(crv*8192) * 0x0001000100010001ULL;

    VAR_0->ubCoeff=   roundToInt16(cbu*8192) * 0x0001000100010001ULL;

    VAR_0->vgCoeff=   roundToInt16(cgv*8192) * 0x0001000100010001ULL;

    VAR_0->ugCoeff=   roundToInt16(cgu*8192) * 0x0001000100010001ULL;

    VAR_0->yOffset=   roundToInt16(oy *   8) * 0x0001000100010001ULL;



    VAR_0->yuv2rgb_y_coeff  = (int16_t)roundToInt16(cy <<13);

    VAR_0->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);

    VAR_0->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13);

    VAR_0->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13);

    VAR_0->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);

    VAR_0->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);



    ff_yuv2rgb_c_init_tables(VAR_0, VAR_1, VAR_2, VAR_5, VAR_6, VAR_7);

    



#if ARCH_PPC && HAVE_ALTIVEC

    if (VAR_0->flags & SWS_CPU_CAPS_ALTIVEC)

        ff_yuv2rgb_init_tables_altivec(VAR_0, VAR_1, VAR_5, VAR_6, VAR_7);

#endif

    return 0;

}

int FUNC_0(SwsContext *VAR_0, const int VAR_1[4], int VAR_2, const int VAR_3[4], int VAR_4, int VAR_5, int VAR_6, int VAR_7)
{ int64_t crv =  VAR_1[0]; int64_t cbu =  VAR_1[1]; int64_t cgu = -VAR_1[2]; int64_t cgv = -VAR_1[3]; int64_t cy  = 1<<16; int64_t oy  = 0; memcpy(VAR_0->srcColorspaceTable, VAR_1, sizeof(int)*4); memcpy(VAR_0->dstColorspaceTable,     VAR_3, sizeof(int)*4); VAR_0->VAR_5= VAR_5; VAR_0->VAR_6  = VAR_6; VAR_0->VAR_7= VAR_7; VAR_0->VAR_2  = VAR_2; VAR_0->VAR_4  = VAR_4; if (isYUV(VAR_0->dstFormat) || isGray(VAR_0->dstFormat)) return -1; VAR_0->uOffset=   0x0400040004000400LL; VAR_0->vOffset=   0x0400040004000400LL; if (!VAR_2) { cy= (cy*255) / 219; oy= 16<<16; } else { crv= (crv*224) / 255; cbu= (cbu*224) / 255; cgu= (cgu*224) / 255; cgv= (cgv*224) / 255; } cy = (cy *VAR_6             )>>16; crv= (crv*VAR_6 * VAR_7)>>32; cbu= (cbu*VAR_6 * VAR_7)>>32; cgu= (cgu*VAR_6 * VAR_7)>>32; cgv= (cgv*VAR_6 * VAR_7)>>32; oy -= 256*VAR_5; VAR_0->yCoeff=    roundToInt16(cy *8192) * 0x0001000100010001ULL; VAR_0->vrCoeff=   roundToInt16(crv*8192) * 0x0001000100010001ULL; VAR_0->ubCoeff=   roundToInt16(cbu*8192) * 0x0001000100010001ULL; VAR_0->vgCoeff=   roundToInt16(cgv*8192) * 0x0001000100010001ULL; VAR_0->ugCoeff=   roundToInt16(cgu*8192) * 0x0001000100010001ULL; VAR_0->yOffset=   roundToInt16(oy *   8) * 0x0001000100010001ULL; VAR_0->yuv2rgb_y_coeff  = (int16_t)roundToInt16(cy <<13); VAR_0->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9); VAR_0->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13); VAR_0->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13); VAR_0->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13); VAR_0->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13); ff_yuv2rgb_c_init_tables(VAR_0, VAR_1, VAR_2, VAR_5, VAR_6, VAR_7); #if ARCH_PPC && HAVE_ALTIVEC
if (VAR_0->flags & SWS_CPU_CAPS_ALTIVEC)
ff_yuv2rgb_init_tables_altivec(VAR_0, VAR_1, VAR_5, VAR_6, VAR_7); #endif
return 0; }