Ticket #318: mpeg2reinit.diff

File mpeg2reinit.diff, 2.0 KB (added by reimar, 20 years ago)

avoid useless reinit

  • libmpcodecs/vd_libmpeg2.c

     
    5656    return CONTROL_UNKNOWN;
    5757}
    5858
     59static int vo_init_format;
     60
    5961// init driver
    6062static int init(sh_video_t *sh){
    6163    vd_libmpeg2_ctx_t *context;
    … …  
    8991
    9092    mpeg2dec->pending_buffer = 0;
    9193    mpeg2dec->pending_length = 0;
     94    vo_init_format = 0;
    9295
    9396    return 1;
    9497}
    … …  
    157160        int type, use_callback;
    158161        mp_image_t* mpi_new;
    159162        unsigned long pw, ph;
     163        static int vo_init_width;
     164        static int vo_init_height;
     165        static float vo_init_aspect;
    160166       
    161167        switch(state){
    162168        case STATE_BUFFER:
    … …  
    176182            // video parameters inited/changed, (re)init libvo:
    177183            if (info->sequence->width >> 1 == info->sequence->chroma_width &&
    178184                info->sequence->height >> 1 == info->sequence->chroma_height) {
     185                if (vo_init_format == 1 && vo_init_aspect == sh->aspect &&
     186                    vo_init_width == info->sequence->picture_width &&
     187                    vo_init_height == info->sequence->picture_height)
     188                  break;
    179189                if(!mpcodecs_config_vo(sh,
    180190                                       info->sequence->picture_width,
    181191                                       info->sequence->picture_height, IMGFMT_YV12)) return 0;
     192                vo_init_format = 1;
    182193            } else if (info->sequence->width >> 1 == info->sequence->chroma_width &&
    183194                info->sequence->height == info->sequence->chroma_height) {
     195                if (vo_init_format == 2 && vo_init_aspect == sh->aspect &&
     196                    vo_init_width == info->sequence->picture_width &&
     197                    vo_init_height == info->sequence->picture_height)
     198                  break;
    184199                if(!mpcodecs_config_vo(sh,
    185200                                       info->sequence->picture_width,
    186201                                       info->sequence->picture_height, IMGFMT_422P)) return 0;
     202                vo_init_format = 2;
    187203            } else return 0;
     204            vo_init_aspect = sh->aspect;
     205            vo_init_width = info->sequence->picture_width;
     206            vo_init_height = info->sequence->picture_height;
    188207            break;
    189208        case STATE_PICTURE:
    190209            type=info->current_picture->flags&PIC_MASK_CODING_TYPE;