[MPlayer-dev-eng] [PATCH] fix "FIXME: save orig w/h, and restore if codec init failed!"

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Jan 26 20:30:14 CET 2007


Hello,
attached patch fixes this FIXME. I do not know of any cases where this
caused problems.
Though it also fixes another inconsistency: when CODECS_FLAG_ALIGN16 is
set, the bih values for width/height take precedence, otherwise not.
With this consistency fix, dimensions get set correctly with
SVQ3-over-rtsp streaming without further code changes.
Does attached patch look okay to you? Any suggestions for
simplification?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/dec_video.c
===================================================================
--- libmpcodecs/dec_video.c	(revision 22020)
+++ libmpcodecs/dec_video.c	(working copy)
@@ -185,6 +185,7 @@
 
     while(1){
 	int i;
+	int orig_w, orig_h;
 	// restore original fourcc:
 	if(sh_video->bih) sh_video->bih->biCompression=orig_fourcc;
 	if(!(sh_video->codec=find_video_codec(sh_video->format,
@@ -238,22 +239,30 @@
 		sh_video->codec->name, sh_video->codec->drv);
 	    continue;
 	}
+	orig_w = sh_video->bih ? sh_video->bih->biWidth : sh_video->disp_w;
+	orig_h = sh_video->bih ? sh_video->bih->biHeight : sh_video->disp_h;
+	sh_video->disp_w = orig_w;
+	sh_video->disp_h = orig_h;
 	// it's available, let's try to init!
 	if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){
 	    // align width/height to n*16
-	    // FIXME: save orig w/h, and restore if codec init failed!
-	    if(sh_video->bih){
-		sh_video->disp_w=sh_video->bih->biWidth=(sh_video->bih->biWidth+15)&(~15);
-		sh_video->disp_h=sh_video->bih->biHeight=(sh_video->bih->biHeight+15)&(~15);
-	    } else {
 		sh_video->disp_w=(sh_video->disp_w+15)&(~15);
 		sh_video->disp_h=(sh_video->disp_h+15)&(~15);
-	    }
 	}
+	if (sh_video->bih) {
+		sh_video->bih->biWidth = sh_video->disp_w;
+		sh_video->bih->biHeight = sh_video->disp_h;
+	}
 	// init()
 	mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_OpeningVideoDecoder,mpvdec->info->short_name,mpvdec->info->name);
 	if(!mpvdec->init(sh_video)){
 	    mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VDecoderInitFailed);
+	    sh_video->disp_w=orig_w;
+	    sh_video->disp_h=orig_h;
+	    if (sh_video->bih) {
+		sh_video->bih->biWidth = sh_video->disp_w;
+		sh_video->bih->biHeight = sh_video->disp_h;
+	    }
 	    continue; // try next...
 	}
 	// Yeah! We got it!


More information about the MPlayer-dev-eng mailing list