printf("%s %s p:%d >>:%d\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "", predictor, point_transform);
av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "", predictor, point_transform);
static int mjpeg_decode_sos(MJpegDecodeContext *s){    int len, nb_components, i, h, v, predictor, point_transform;    int vmax, hmax, index, id;    const int block_size= s->lossless ? 1 : 8;    /* XXX: verify len field validity */    len = get_bits(&s->gb, 16);    nb_components = get_bits(&s->gb, 8);    if (len != 6+2*nb_components)    {	dprintf("decode_sos: invalid len (%d)\n", len);	return -1;    }    /* XXX: only interleaved scan accepted */    if (nb_components != 3)    {	dprintf("decode_sos: components(%d) mismatch\n", nb_components);        return -1;    }    vmax = 0;    hmax = 0;    for(i=0;i<nb_components;i++) {        id = get_bits(&s->gb, 8) - 1;	dprintf("component: %d\n", id);        /* find component index */        for(index=0;index<s->nb_components;index++)            if (id == s->component_id[index])                break;        if (index == s->nb_components)	{	    dprintf("decode_sos: index(%d) out of components\n", index);            return -1;	}        s->comp_index[i] = index;        s->nb_blocks[i] = s->h_count[index] * s->v_count[index];        s->h_scount[i] = s->h_count[index];        s->v_scount[i] = s->v_count[index];        s->dc_index[i] = get_bits(&s->gb, 4);        s->ac_index[i] = get_bits(&s->gb, 4);	if (s->dc_index[i] <  0 || s->ac_index[i] < 0 ||	    s->dc_index[i] >= 4 || s->ac_index[i] >= 4)	    goto out_of_range;#if 0 //buggy	switch(s->start_code)	{	    case SOF0:		if (dc_index[i] > 1 || ac_index[i] > 1)		    goto out_of_range;		break;	    case SOF1:	    case SOF2:		if (dc_index[i] > 3 || ac_index[i] > 3)		    goto out_of_range;		break;	    case SOF3:		if (dc_index[i] > 3 || ac_index[i] != 0)		    goto out_of_range;		break;		}#endif    }    predictor= get_bits(&s->gb, 8); /* lossless predictor or start of spectral (Ss) */    skip_bits(&s->gb, 8); /* Se */    skip_bits(&s->gb, 4); /* Ah */    point_transform= get_bits(&s->gb, 4); /* Al */    for(i=0;i<nb_components;i++)         s->last_dc[i] = 1024;    if (nb_components > 1) {        /* interleaved stream */        s->mb_width  = (s->width  + s->h_max * block_size - 1) / (s->h_max * block_size);        s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);    } else {        h = s->h_max / s->h_scount[s->comp_index[0]];        v = s->v_max / s->v_scount[s->comp_index[0]];        s->mb_width  = (s->width  + h * block_size - 1) / (h * block_size);        s->mb_height = (s->height + v * block_size - 1) / (v * block_size);        s->nb_blocks[0] = 1;        s->h_scount[0] = 1;        s->v_scount[0] = 1;    }    if(s->avctx->debug & FF_DEBUG_PICT_INFO)        printf("%s %s p:%d >>:%d\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "", predictor, point_transform);        if(s->lossless){            if(s->rgb){                if(ljpeg_decode_rgb_scan(s, predictor, point_transform) < 0)                    return -1;            }else{                if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)                    return -1;            }    }else{        if(mjpeg_decode_scan(s) < 0)            return -1;    }    emms_c();    return 0; out_of_range:    dprintf("decode_sos: ac/dc index out of range\n");    return -1;}