if (!s1->mpeg_enc_ctx_allocated)
if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr)
static int slice_end(AVCodecContext *avctx, AVFrame *pict){    Mpeg1Context *s1 = avctx->priv_data;    MpegEncContext *s = &s1->mpeg_enc_ctx;           if (!s1->mpeg_enc_ctx_allocated)        return 0;#ifdef HAVE_XVMC    if(s->avctx->xvmc_acceleration)        XVMC_field_end(s);#endif    /* end of slice reached */    if (/*s->mb_y<<field_pic == s->mb_height &&*/ !s->first_field) {        /* end of image */        if(s->mpeg2){            s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG2;        }else            s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG1;        ff_er_frame_end(s);        MPV_frame_end(s);        if (s->pict_type == B_TYPE || s->low_delay) {            *pict= *(AVFrame*)s->current_picture_ptr;            ff_print_debug_info(s, s->current_picture_ptr);        } else {            s->picture_number++;            /* latency of 1 frame for I and P frames */            /* XXX: use another variable than picture_number */            if (s->last_picture_ptr != NULL) {                *pict= *(AVFrame*)s->last_picture_ptr;                 ff_print_debug_info(s, s->last_picture_ptr);            }        }        if(s->avctx->codec_tag == ff_get_fourcc("VCR2"))            exchange_uv(pict);        return 1;    } else {        return 0;    }}