s->rct=1;
s->pegasus_rct=1;
static int mjpeg_decode_app(MJpegDecodeContext *s){    int len, id;    /* XXX: verify len field validity */    len = get_bits(&s->gb, 16);    if (len < 5)	return -1;    id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16);    id = be2me_32(id);    len -= 6;    if(s->avctx->debug & FF_DEBUG_STARTCODE){        printf("APPx %8X\n", id);     }        /* buggy AVID, it puts EOI only at every 10th frame */    /* also this fourcc is used by non-avid files too, it holds some       informations, but it's always present in AVID creates files */    if (id == ff_get_fourcc("AVI1"))    {	/* structure:	    4bytes	AVI1	    1bytes	polarity	    1bytes	always zero	    4bytes	field_size	    4bytes	field_size_less_padding	*/    	s->buggy_avid = 1;//	if (s->first_picture)//	    printf("mjpeg: workarounding buggy AVID\n");	s->interlace_polarity = get_bits(&s->gb, 8);#if 0	skip_bits(&s->gb, 8);	skip_bits(&s->gb, 32);	skip_bits(&s->gb, 32);	len -= 10;#endif//	if (s->interlace_polarity)//	    printf("mjpeg: interlace polarity: %d\n", s->interlace_polarity);	goto out;    }    //    len -= 2;        if (id == ff_get_fourcc("JFIF"))    {	int t_w, t_h;	skip_bits(&s->gb, 8); /* the trailing zero-byte */	printf("mjpeg: JFIF header found (version: %x.%x)\n",	    get_bits(&s->gb, 8), get_bits(&s->gb, 8));	if (get_bits(&s->gb, 8) == 0)	{	    int x_density, y_density; 	    x_density = get_bits(&s->gb, 16);	    y_density = get_bits(&s->gb, 16);	    dprintf("x/y density: %d (%f), %d (%f)\n", x_density,		(float)x_density, y_density, (float)y_density);#if 0            //MN: needs to be checked            if(x_density)//                s->avctx->aspect_ratio= s->width*y_density/((float)s->height*x_density);		s->avctx->aspect_ratio = (float)x_density/y_density;		/* it's better, but every JFIF I have seen stores 1:1 */            else                s->avctx->aspect_ratio= 0.0;#endif	}	else	{	    skip_bits(&s->gb, 16);	    skip_bits(&s->gb, 16);	}	t_w = get_bits(&s->gb, 8);	t_h = get_bits(&s->gb, 8);	if (t_w && t_h)	{	    /* skip thumbnail */	    if (len-10-(t_w*t_h*3) > 0)		len -= t_w*t_h*3;	}	len -= 10;	goto out;    }        if (id == ff_get_fourcc("Adob") && (get_bits(&s->gb, 8) == 'e'))    {	printf("mjpeg: Adobe header found\n");	skip_bits(&s->gb, 16); /* version */	skip_bits(&s->gb, 16); /* flags0 */	skip_bits(&s->gb, 16); /* flags1 */	skip_bits(&s->gb, 8); /* transform */	len -= 7;	goto out;    }    if (id == ff_get_fourcc("LJIF")){        printf("Pegasus lossless jpeg header found\n");	skip_bits(&s->gb, 16); /* version ? */	skip_bits(&s->gb, 16); /* unknwon always 0? */	skip_bits(&s->gb, 16); /* unknwon always 0? */	skip_bits(&s->gb, 16); /* unknwon always 0? */        switch( get_bits(&s->gb, 8)){        case 1:            s->rgb= 1;            s->rct=0;            break;        case 2:            s->rgb= 1;            s->rct=1;            break;        default:            printf("unknown colorspace\n");        }        len -= 9;        goto out;    }        /* Apple MJPEG-A */    if ((s->start_code == APP1) && (len > (0x28 - 8)))    {	id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16);	id = be2me_32(id);	len -= 4;	if (id == ff_get_fourcc("mjpg")) /* Apple MJPEG-A */	{#if 0	    skip_bits(&s->gb, 32); /* field size */	    skip_bits(&s->gb, 32); /* pad field size */	    skip_bits(&s->gb, 32); /* next off */	    skip_bits(&s->gb, 32); /* quant off */	    skip_bits(&s->gb, 32); /* huff off */	    skip_bits(&s->gb, 32); /* image off */	    skip_bits(&s->gb, 32); /* scan off */	    skip_bits(&s->gb, 32); /* data off */#endif	    if (s->first_picture)		printf("mjpeg: Apple MJPEG-A header found\n");	}    }out:    /* slow but needed for extreme adobe jpegs */    if (len < 0)	printf("mjpeg: error, decode_app parser read over the end\n");    while(--len > 0)	skip_bits(&s->gb, 8);    return 0;}