dprintf(" %d", s->inter_matrix[s->dsp.idct_permutation[i]);
dprintf(" %d", s->inter_matrix[s->dsp.idct_permutation[i]]);
static int mpeg1_decode_sequence(AVCodecContext *avctx,                                  const uint8_t *buf, int buf_size){    Mpeg1Context *s1 = avctx->priv_data;    MpegEncContext *s = &s1->mpeg_enc_ctx;    int width,height;    int i, v, j;    init_get_bits(&s->gb, buf, buf_size*8);    width = get_bits(&s->gb, 12);    height = get_bits(&s->gb, 12);    if (width <= 0 || height <= 0 ||        (width % 2) != 0 || (height % 2) != 0)        return -1;    s->aspect_ratio_info= get_bits(&s->gb, 4);    if (s->aspect_ratio_info == 0)        return -1;    s->frame_rate_index = get_bits(&s->gb, 4);    if (s->frame_rate_index == 0 || s->frame_rate_index > 13)        return -1;    s->bit_rate = get_bits(&s->gb, 18) * 400;    if (get_bits1(&s->gb) == 0) /* marker */        return -1;    s->width = width;    s->height = height;    s->avctx->rc_buffer_size= get_bits(&s->gb, 10) * 1024*16;    skip_bits(&s->gb, 1);    /* get matrix */    if (get_bits1(&s->gb)) {        for(i=0;i<64;i++) {            v = get_bits(&s->gb, 8);            if(v==0){                av_log(s->avctx, AV_LOG_ERROR, "intra matrix damaged\n");                return -1;            }            j = s->dsp.idct_permutation[ ff_zigzag_direct[i] ];            s->intra_matrix[j] = v;            s->chroma_intra_matrix[j] = v;        }#ifdef DEBUG        dprintf("intra matrix present\n");        for(i=0;i<64;i++)            dprintf(" %d", s->intra_matrix[s->dsp.idct_permutation[i]);        printf("\n");#endif    } else {        for(i=0;i<64;i++) {            j = s->dsp.idct_permutation[i];            v = ff_mpeg1_default_intra_matrix[i];            s->intra_matrix[j] = v;            s->chroma_intra_matrix[j] = v;        }    }    if (get_bits1(&s->gb)) {        for(i=0;i<64;i++) {            v = get_bits(&s->gb, 8);            if(v==0){                av_log(s->avctx, AV_LOG_ERROR, "inter matrix damaged\n");                return -1;            }            j = s->dsp.idct_permutation[ ff_zigzag_direct[i] ];            s->inter_matrix[j] = v;            s->chroma_inter_matrix[j] = v;        }#ifdef DEBUG        dprintf("non intra matrix present\n");        for(i=0;i<64;i++)            dprintf(" %d", s->inter_matrix[s->dsp.idct_permutation[i]);        printf("\n");#endif    } else {        for(i=0;i<64;i++) {            int j= s->dsp.idct_permutation[i];            v = ff_mpeg1_default_non_intra_matrix[i];            s->inter_matrix[j] = v;            s->chroma_inter_matrix[j] = v;        }    }        if(show_bits(&s->gb, 23) != 0){        av_log(s->avctx, AV_LOG_ERROR, "sequence header damaged\n");        return -1;    }    /* we set mpeg2 parameters so that it emulates mpeg1 */    s->progressive_sequence = 1;    s->progressive_frame = 1;    s->picture_structure = PICT_FRAME;    s->frame_pred_frame_dct = 1;    s->chroma_format = 1;    s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG1VIDEO;    avctx->sub_id = 1; /* indicates mpeg1 */    s->out_format = FMT_MPEG1;    s->swap_uv = 0;//AFAIK VCR2 don't have SEQ_HEADER    if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1;        if(s->avctx->debug & FF_DEBUG_PICT_INFO)        av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%d\n",                s->avctx->rc_buffer_size, s->bit_rate);        return 0;}