changeset 25977:e3be2de66969

Avoid reinit of vo with the exactly same parameters over and over.
author reimar
date Sat, 16 Feb 2008 14:31:34 +0000
parents 7e297cec88aa
children a8ff60976ccb
files libmpcodecs/vd_libmpeg2.c
diffstat 1 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_libmpeg2.c	Sat Feb 16 11:51:41 2008 +0000
+++ b/libmpcodecs/vd_libmpeg2.c	Sat Feb 16 14:31:34 2008 +0000
@@ -32,6 +32,10 @@
     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 @@
 	int type, use_callback;
 	mp_image_t* mpi_new;
 	unsigned long pw, ph;
+	int imgfmt;
 	
 	switch(state){
 	case STATE_BUFFER:
@@ -176,15 +181,24 @@
 	    // 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;