printf("qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
static int mpeg_decode_slice(AVCodecContext *avctx,                               AVFrame *pict,                              int start_code,                              uint8_t **buf, int buf_size){    Mpeg1Context *s1 = avctx->priv_data;    MpegEncContext *s = &s1->mpeg_enc_ctx;    int ret;    const int field_pic= s->picture_structure != PICT_FRAME;    s->resync_mb_x= s->mb_x =     s->resync_mb_y= s->mb_y = -1;        start_code = (start_code - 1) & 0xff;    if (start_code >= s->mb_height){        fprintf(stderr, "slice below image (%d >= %d)\n", start_code, s->mb_height);        return -1;    }        ff_mpeg1_clean_buffers(s);    s->interlaced_dct = 0;            /* start frame decoding */    if (s->first_slice) {      if(s->first_field || s->picture_structure==PICT_FRAME){        if(MPV_frame_start(s, avctx) < 0)            return DECODE_SLICE_FATAL_ERROR;        ff_er_frame_start(s);        /* first check if we must repeat the frame */        s->current_picture_ptr->repeat_pict = 0;        if (s->repeat_first_field) {            if (s->progressive_sequence) {                if (s->top_field_first)                    s->current_picture_ptr->repeat_pict = 4;                else                    s->current_picture_ptr->repeat_pict = 2;            } else if (s->progressive_frame) {                s->current_picture_ptr->repeat_pict = 1;            }        }                 *s->current_picture_ptr->pan_scan= s1->pan_scan;        //printf("%d\n", s->current_picture_ptr->repeat_pict);        if(s->avctx->debug&FF_DEBUG_PICT_INFO){             printf("qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",                  s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1],                 s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")),                  s->progressive_sequence ? "pro" :"", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"",                  s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors,                 s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :"");        }      }else{ //second field            int i;                        if(!s->current_picture_ptr){                fprintf(stderr, "first field missing\n");                return -1;            }                        for(i=0; i<4; i++){                s->current_picture.data[i] = s->current_picture_ptr->data[i];                if(s->picture_structure == PICT_BOTTOM_FIELD){                    s->current_picture.data[i] += s->current_picture_ptr->linesize[i];                }             }      }#ifdef HAVE_XVMC// MPV_frame_start will call this function too,// but we need to call it on every field      if(s->avctx->xvmc_acceleration)         XVMC_field_start(s,avctx);#endif    }//fi(s->first_slice)    s->first_slice = 0;    init_get_bits(&s->gb, *buf, buf_size*8);    s->qscale = get_qscale(s);    if(s->qscale == 0){        fprintf(stderr, "qscale == 0\n");        return -1;    }        /* extra slice info */    while (get_bits1(&s->gb) != 0) {        skip_bits(&s->gb, 8);    }        s->mb_x=0;    for(;;) {        int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);        if (code < 0){            fprintf(stderr, "first mb_incr damaged\n");            return -1;        }        if (code >= 33) {            if (code == 33) {                s->mb_x += 33;            }            /* otherwise, stuffing, nothing to do */        } else {            s->mb_x += code;            break;        }    }        s->resync_mb_x= s->mb_x;    s->resync_mb_y= s->mb_y = start_code;    s->mb_skip_run= 0;    ff_init_block_index(s);    for(;;) {#ifdef HAVE_XVMC        //one 1 we memcpy blocks in xvmcvideo        if(s->avctx->xvmc_acceleration > 1)            XVMC_init_block(s);//set s->block#endif	s->dsp.clear_blocks(s->block[0]);        ret = mpeg_decode_mb(s, s->block);        dprintf("ret=%d\n", ret);        if (ret < 0)            return -1;                    if(s->motion_val && s->pict_type != B_TYPE){ //note motion_val is normally NULL unless we want to extract the MVs            const int wrap = s->block_wrap[0];            const int xy = s->mb_x*2 + 1 + (s->mb_y*2 +1)*wrap;            int motion_x, motion_y;            if (s->mb_intra) {                motion_x = motion_y = 0;            }else if (s->mv_type == MV_TYPE_16X16) {                motion_x = s->mv[0][0][0];                motion_y = s->mv[0][0][1];            } else /*if (s->mv_type == MV_TYPE_FIELD)*/ {                motion_x = s->mv[0][0][0] + s->mv[0][1][0];                motion_y = s->mv[0][0][1] + s->mv[0][1][1];                motion_x = (motion_x>>1) | (motion_x&1);            }            s->motion_val[xy][0] = motion_x;            s->motion_val[xy][1] = motion_y;            s->motion_val[xy + 1][0] = motion_x;            s->motion_val[xy + 1][1] = motion_y;            s->motion_val[xy + wrap][0] = motion_x;            s->motion_val[xy + wrap][1] = motion_y;            s->motion_val[xy + 1 + wrap][0] = motion_x;            s->motion_val[xy + 1 + wrap][1] = motion_y;        }                s->dest[0] += 16;        s->dest[1] += 8;        s->dest[2] += 8;        MPV_decode_mb(s, s->block);                if (++s->mb_x >= s->mb_width) {            ff_draw_horiz_band(s, 16*s->mb_y, 16);            s->mb_x = 0;            s->mb_y++;            if(s->mb_y<<field_pic >= s->mb_height){                int left= s->gb.size_in_bits - get_bits_count(&s->gb);                if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)))                   || (avctx->error_resilience >= FF_ER_AGGRESSIVE && left>8)){                    fprintf(stderr, "end missmatch left=%d\n", left);                    return -1;                }else                    goto eos;            }                        ff_init_block_index(s);        }        /* skip mb handling */        if (s->mb_skip_run == -1) {            /* read again increment */            s->mb_skip_run = 0;            for(;;) {                int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);                if (code < 0){                    fprintf(stderr, "mb incr damaged\n");                    return -1;                }                if (code >= 33) {                    if (code == 33) {                        s->mb_skip_run += 33;                    }else if(code == 35){                        if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){                            fprintf(stderr, "slice missmatch\n");                            return -1;                        }                        goto eos; /* end of slice */                    }                    /* otherwise, stuffing, nothing to do */                } else {                    s->mb_skip_run += code;                    break;                }            }        }    }eos: // end of slice    *buf += get_bits_count(&s->gb)/8 - 1;//printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);    return 0;}