[Mplayer-cvslog] CVS: main/libmpdemux aviheader.c, 1.53, 1.54 muxer.h, 1.10, 1.11 muxer_avi.c, 1.21, 1.22

Tobias Diedrich CVS syncmail at mplayerhq.hu
Wed Mar 24 16:16:39 CET 2004


CVS change done by Tobias Diedrich CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv31245/libmpdemux

Modified Files:
	aviheader.c muxer.h muxer_avi.c 
Log Message:
Use aspect from encoder for AVI vprp header

Index: aviheader.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/aviheader.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- aviheader.c	22 Mar 2004 01:42:43 -0000	1.53
+++ aviheader.c	24 Mar 2004 15:16:36 -0000	1.54
@@ -28,8 +28,6 @@
 extern void print_avistdindex_chunk(avistdindex_chunk *h);
 extern void print_avisuperindex_chunk(avisuperindex_chunk *h);
 
-int avi_use_vprp_aspect = 0;
-
 static int odml_get_vstream_id(int id, unsigned char res[])
 {
     unsigned char *p = (unsigned char *)&id;
@@ -345,7 +343,7 @@
 	for (i=0; i<vprp->nbFieldPerFrame; i++) {
 		le2me_VIDEO_FIELD_DESC(&vprp->FieldInfo[i]);
 	}
-	if (avi_use_vprp_aspect && sh_video) {
+	if (sh_video) {
 		sh_video->aspect = GET_AVI_ASPECT(vprp->dwFrameAspectRatio);
 	}
 	if(verbose>=1) print_vprp(vprp);

Index: muxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- muxer.h	17 Mar 2004 14:50:37 -0000	1.10
+++ muxer.h	24 Mar 2004 15:16:36 -0000	1.11
@@ -17,6 +17,7 @@
   uint32_t ckid; // chunk id (00dc 01wb etc)
   double timer;
   off_t size;
+  float aspect; // aspect ratio of this stream (set by ve_*.c)
   // buffering:
   unsigned char *buffer;
   unsigned int buffer_size;

Index: muxer_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_avi.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- muxer_avi.c	22 Mar 2004 01:42:43 -0000	1.21
+++ muxer_avi.c	24 Mar 2004 15:16:36 -0000	1.22
@@ -34,7 +34,7 @@
 #define ODML_NOTKEYFRAME 0x80000000U
 #define MOVIALIGN        0x00001000
 
-extern int avi_use_vprp_aspect;
+float avi_aspect_override = -1.0;
 
 struct avi_odmlidx_entry {
 	uint64_t ofs;
@@ -57,6 +57,35 @@
 	struct avi_odmlsuperidx_entry *superidx;
 };
 
+static unsigned int avi_aspect(muxer_stream_t *vstream)
+{
+    int x,y;
+    float aspect = vstream->aspect;
+
+    if (avi_aspect_override > 0.0) {
+        aspect = avi_aspect_override;
+    }
+
+    if (aspect <= 0.0) return 0;
+
+    if (aspect > 15.99/9.0 && aspect < 16.01/9.0) {
+        return MAKE_AVI_ASPECT(16, 9);
+    }
+    if (aspect > 3.99/3.0 && aspect < 4.01/3.0) {
+        return MAKE_AVI_ASPECT(4, 3);
+    }
+
+    if (aspect >= 1.0) {
+        x = 16384;
+        y = (float)x / aspect;
+    } else {
+        y = 16384;
+        x = (float)y * aspect;
+    }
+
+    return MAKE_AVI_ASPECT(x, y);
+}
+
 static muxer_stream_t* avifile_new_stream(muxer_t *muxer,int type){
     struct avi_stream_info *si;
     muxer_stream_t* s;
@@ -225,21 +254,6 @@
 
 #define WFSIZE(wf) (sizeof(WAVEFORMATEX)+(wf)->cbSize)
 
-static unsigned int avi_aspect(float aspect)
-{
-    if (aspect <= 0.0) {
-    	aspect = 4.0/3.0;
-    }
-    if (aspect >= 3.99/3.0 &&
-        aspect <= 4.01/3.0) return MAKE_AVI_ASPECT(4,3);
-    if (aspect >= 15.99/9.0 &&
-        aspect <= 16.01/9.0) return MAKE_AVI_ASPECT(16,9);
-    if (aspect >= 0.99 &&
-        aspect <= 1.01) return MAKE_AVI_ASPECT(1,1);
-    if (aspect<1.0) return MAKE_AVI_ASPECT((int)(aspect*8192),8192);
-    return MAKE_AVI_ASPECT(8192,(int)(8192/aspect));
-}
-
 static void avifile_write_header(muxer_t *muxer){
   uint32_t riff[3];
   unsigned int dmlh[1];
@@ -248,10 +262,16 @@
   muxer_info_t info[16];
   FILE *f = muxer->file;
   VideoPropHeader vprp;
-
+  uint32_t aspect = avi_aspect(muxer->def_v);
   off_t pos;
   int isodml = muxer->file_end > ODML_CHUNKLEN ? 1 : 0;
 
+  if (aspect == 0) {
+    mp_msg(MSGT_MUXER, MSGL_INFO, "ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.\n");
+  } else {
+    mp_msg(MSGT_MUXER, MSGL_INFO, "ODML: vprp aspect is %d:%d.\n", aspect >> 16, aspect & 0xffff);
+  }
+
   if (isodml) {
     for (pos = 0; pos < muxer->file_end; pos += ODML_CHUNKLEN) {
       unsigned int rifflen, movilen;
@@ -316,7 +336,7 @@
       switch(muxer->streams[i]->type){
       case MUXER_TYPE_VIDEO:
           hdrsize+=muxer->streams[i]->bih->biSize+8; // strf
-	  if (avi_use_vprp_aspect) {
+	  if (aspect != 0) {
 	      hdrsize+=8+4*(9+8*1); // vprp
 	  }
 	  break;
@@ -351,14 +371,13 @@
           s->h.fccHandler = s->bih->biCompression;
           s->h.rcFrame.right = s->bih->biWidth;
           s->h.rcFrame.bottom = s->bih->biHeight;
-	  if (avi_use_vprp_aspect) {
-	      sh_video_t *sh_video = s->source;
+	  if (aspect != 0) {
 	      // fill out vprp info
 	      memset(&vprp, 0, sizeof(vprp));
 	      vprp.dwVerticalRefreshRate = (s->h.dwRate+s->h.dwScale-1)/s->h.dwScale;
 	      vprp.dwHTotalInT = muxer->avih.dwWidth;
 	      vprp.dwVTotalInLines = muxer->avih.dwHeight;
-	      vprp.dwFrameAspectRatio = avi_aspect(sh_video->aspect);
+	      vprp.dwFrameAspectRatio = aspect;
 	      vprp.dwFrameWidthInPixels = muxer->avih.dwWidth;
 	      vprp.dwFrameHeightInLines = muxer->avih.dwHeight;
 	      vprp.nbFieldPerFrame = 1;
@@ -388,7 +407,7 @@
           write_avi_chunk(f,ckidSTREAMFORMAT,biSize,s->bih); /* BITMAPINFOHEADER */
           le2me_BITMAPINFOHEADER(s->bih);
 
-	  if (avi_use_vprp_aspect) {
+	  if (aspect != 0) {
 	      int fields = vprp.nbFieldPerFrame;
 	      le2me_VideoPropHeader(&vprp);
 	      le2me_VIDEO_FIELD_DESC(&vprp.FieldInfo[0]);




More information about the MPlayer-cvslog mailing list