From 539ab7489e4b462c1595ddffe1ff3201d7f18bec Mon Sep 17 00:00:00 2001 From: reimar Date: Sat, 16 Feb 2008 14:31:34 +0000 Subject: Avoid reinit of vo with the exactly same parameters over and over. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26009 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vd_libmpeg2.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'libmpcodecs') diff --git a/libmpcodecs/vd_libmpeg2.c b/libmpcodecs/vd_libmpeg2.c index 81c1a1d8a3..4dbb807750 100644 --- a/libmpcodecs/vd_libmpeg2.c +++ b/libmpcodecs/vd_libmpeg2.c @@ -32,6 +32,10 @@ typedef struct { mpeg2dec_t *mpeg2dec; int quant_store_idx; char *quant_store[3]; + int imgfmt; + int width; + int height; + double aspect; } vd_libmpeg2_ctx_t; // to set/get/query special features/parameters @@ -157,6 +161,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ int type, use_callback; mp_image_t* mpi_new; unsigned long pw, ph; + int imgfmt; switch(state){ case STATE_BUFFER: @@ -176,15 +181,24 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ // video parameters initialized/changed, (re)init libvo: if (info->sequence->width >> 1 == info->sequence->chroma_width && info->sequence->height >> 1 == info->sequence->chroma_height) { - if(!mpcodecs_config_vo(sh, - info->sequence->picture_width, - info->sequence->picture_height, IMGFMT_YV12)) return 0; + imgfmt = IMGFMT_YV12; } else if (info->sequence->width >> 1 == info->sequence->chroma_width && info->sequence->height == info->sequence->chroma_height) { - if(!mpcodecs_config_vo(sh, - info->sequence->picture_width, - info->sequence->picture_height, IMGFMT_422P)) return 0; + imgfmt = IMGFMT_422P; } else return 0; + if (imgfmt == context->imgfmt && + info->sequence->picture_width == context->width && + info->sequence->picture_height == context->height && + sh->aspect == context->aspect) + break; + if(!mpcodecs_config_vo(sh, + info->sequence->picture_width, + info->sequence->picture_height, imgfmt)) + return 0; + context->imgfmt = imgfmt; + context->width = info->sequence->picture_width; + context->height = info->sequence->picture_height; + context->aspect = sh->aspect; break; case STATE_PICTURE: type=info->current_picture->flags&PIC_MASK_CODING_TYPE; -- cgit v1.2.3