planep[0] = planep[-width];
planep += stride; planep[0] ^= planep[-stride];
static int bitplane_decoding(uint8_t* plane, int width, int height, VC9Context *v){    int imode, x, y, code;    uint8_t invert, *planep = plane;    invert = get_bits(&v->gb, 1);    imode = get_vlc2(&v->gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2);    av_log(v->avctx, AV_LOG_DEBUG, "Bitplane: imode=%i, invert=%i\n",           imode, invert);    switch (imode)    {    case IMODE_RAW:        for (y=0; y<height; y++)        {            for (x=0; x<width; x++)                planep[x] = (-get_bits(&v->gb, 1)); //-1=0xFF            planep += width;        }        break;    case IMODE_DIFF2:    case IMODE_NORM2:        if ((height*width) & 1) *(++planep) = get_bits(&v->gb, 1);        code = get_vlc2(&v->gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2);        *(++planep) = code&1; //lsb => left        *(++planep) = code&2; //msb => right - this is a bitplane, so only !0 matters        break;    case IMODE_DIFF6:    case IMODE_NORM6:        av_log(v->avctx, AV_LOG_ERROR, "Imode using Norm-6 isn't supported\n");        return -1;        break;    case IMODE_ROWSKIP:        for (y=0; y<height; y++)        {            if (get_bits(&v->gb, 1)) //rowskip              memset(planep, 0, width);            else for (x=0; x<width; x++) planep[x] = get_bits(&v->gb, 1);            planep += width;        }        break;    case IMODE_COLSKIP: //Teh ugly        for (x=0; x<width; x++)        {            planep = plane;            if (get_bits(&v->gb, 1)) //colskip            {                for (y=0; y<height; y++)                {                    planep[x] = 0;                    planep += width;                }            }            else            {                for (y=0; y<height; y++)                {                    planep[x] = get_bits(&v->gb, 1);                    planep += width;                }            }        }        break;    default: break;    }    /* Applying diff operator */    if (imode == IMODE_DIFF2 || imode == IMODE_DIFF2)    {        /* And what about j=0 !? */        planep = plane + width;        memset(plane, invert, width);        for (y=0; y<height; y++)        {            planep[0] = planep[-width];            for (x=1; x<width; x++)            {                if (planep[x-1] != planep[-width]) planep[x] = invert;                else planep[x] = planep[x-1];            }            planep += width;        }    }    else if (invert)    {        planep = plane;        for (x=0; x<width*height; x++) planep[x] = !planep[x];    }    return 0;}