av_div_q( mpeg2_aspect[s->aspect_ratio_info], (AVRational){s->width, s->height} );
mpeg2_aspect[s->aspect_ratio_info];
static int mpeg_decode_postinit(AVCodecContext *avctx){Mpeg1Context *s1 = avctx->priv_data;MpegEncContext *s = &s1->mpeg_enc_ctx;uint8_t old_permutation[64];    if (    	(s1->mpeg_enc_ctx_allocated == 0)||         avctx->width  != s->width ||        avctx->height != s->height||//      s1->save_aspect_info != avctx->aspect_ratio_info||        0)    {            if (s1->mpeg_enc_ctx_allocated) {            MPV_common_end(s);        }	if( (s->width == 0 )||(s->height == 0))	    return -2;        avctx->width = s->width;        avctx->height = s->height;        avctx->bit_rate = s->bit_rate;        s1->save_aspect_info = s->aspect_ratio_info;     //low_delay may be forced, in this case we will have B frames     //that behave like P frames        avctx->has_b_frames = !(s->low_delay);        if(avctx->sub_id==1){//s->codec_id==avctx->codec_id==CODEC_ID            //mpeg1 fps            avctx->frame_rate     = frame_rate_tab[s->frame_rate_index].num;            avctx->frame_rate_base= frame_rate_tab[s->frame_rate_index].den;            //mpeg1 aspect            avctx->sample_aspect_ratio= av_d2q(                    1.0/mpeg1_aspect[s->aspect_ratio_info], 255);        }else{//mpeg2        //mpeg2 fps            av_reduce(                &s->avctx->frame_rate,                 &s->avctx->frame_rate_base,                 frame_rate_tab[s->frame_rate_index].num * (s->frame_rate_ext_n+1),                frame_rate_tab[s->frame_rate_index].den * (s->frame_rate_ext_d+1),                1<<30);        //mpeg2 aspect            if(s->aspect_ratio_info > 1){                if( (s1->display_weight == 0 )||(s1->display_height == 0) ){                    s->avctx->sample_aspect_ratio=                         mpeg2_aspect[s->aspect_ratio_info];                }else{                    s->avctx->sample_aspect_ratio=                         av_div_q(                         mpeg2_aspect[s->aspect_ratio_info],                          (AVRational){s1->display_weight, s1->display_height}                        );        	}            }else{                s->avctx->sample_aspect_ratio=                     av_div_q(                     mpeg2_aspect[s->aspect_ratio_info],                      (AVRational){s->width, s->height}                    );            }        }//mpeg2        if(avctx->xvmc_acceleration){            avctx->pix_fmt = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420);        }else{            if(s->chroma_format <  2){                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_yuv_420);            }else            if(s->chroma_format == 2){                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_yuv_422);            }else            if(s->chroma_format >  2){                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_yuv_444);            }        }        //until then pix_fmt may be changed right after codec init        if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT )            if( avctx->idct_algo == FF_IDCT_AUTO )                avctx->idct_algo = FF_IDCT_SIMPLE;        //quantization matrixes may need reordering         //if dct permutation is changed        memcpy(old_permutation,s->dsp.idct_permutation,64*sizeof(uint8_t));        if (MPV_common_init(s) < 0)            return -2;        quant_matrix_rebuild(s->intra_matrix,       old_permutation,s->dsp.idct_permutation);        quant_matrix_rebuild(s->inter_matrix,       old_permutation,s->dsp.idct_permutation);        quant_matrix_rebuild(s->chroma_intra_matrix,old_permutation,s->dsp.idct_permutation);        quant_matrix_rebuild(s->chroma_inter_matrix,old_permutation,s->dsp.idct_permutation);        s1->mpeg_enc_ctx_allocated = 1;    }    return 0;}