[MPlayer-cvslog] r26009 - trunk/libmpcodecs/vd_libmpeg2.c

reimar subversion at mplayerhq.hu
Sat Feb 16 15:31:35 CET 2008


Author: reimar
Date: Sat Feb 16 15:31:34 2008
New Revision: 26009

Log:
Avoid reinit of vo with the exactly same parameters over and over.


Modified:
   trunk/libmpcodecs/vd_libmpeg2.c

Modified: trunk/libmpcodecs/vd_libmpeg2.c
==============================================================================
--- trunk/libmpcodecs/vd_libmpeg2.c	(original)
+++ trunk/libmpcodecs/vd_libmpeg2.c	Sat Feb 16 15:31:34 2008
@@ -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
 	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
 	    // 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;



More information about the MPlayer-cvslog mailing list