[Mplayer-cvslog] CVS: main/libmpdemux demux_mov.c,1.54,1.55 parse_mp4.c,1.2,1.3 parse_mp4.h,1.1,1.2

Atmosfear atmos4 at mplayer.dev.hu
Sun Mar 24 07:10:25 CET 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv20693/libmpdemux

Modified Files:
	demux_mov.c parse_mp4.c parse_mp4.h 
Log Message:
- Add parsing of Sync Layer Descriptor
- Add a function to cleanup malloced mem from mp4_parse_esds
- Fix some weird code from me :)


Index: demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mov.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- demux_mov.c	24 Mar 2002 03:07:18 -0000	1.54
+++ demux_mov.c	24 Mar 2002 06:10:12 -0000	1.55
@@ -706,21 +706,17 @@
 		      case MOV_FOURCC('e','s','d','s'): {
 			mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len);
 			if(atom_len >= 8) {
-			  esds_t *esds = (esds_t *)malloc(sizeof(esds_t)); 				  
-			  if(esds && !mp4_parse_esds(&trak->stdata[36], atom_len-8, esds)) {
+			  esds_t esds; 				  
+			  if(!mp4_parse_esds(&trak->stdata[36], atom_len-8, &esds)) {
 			    
-			    sh->i_bps = esds->avgBitrate/8; 
+			    sh->i_bps = esds.avgBitrate/8; 
 
 			    // dump away the codec specific configuration for the AAC decoder
-			    sh->codecdata_len = esds->decoderConfigLen;
+			    sh->codecdata_len = esds.decoderConfigLen;
 			    sh->codecdata = (unsigned char *)malloc(sh->codecdata_len);
-			    memcpy(sh->codecdata, esds->decoderConfig, sh->codecdata_len);
-			  }
-			  if(esds) {
-			    if(esds->decoderConfig)
-			      free(esds->decoderConfig);
-			    free(esds);
+			    memcpy(sh->codecdata, esds.decoderConfig, sh->codecdata_len);
 			  }
+			  mp4_free_esds(&esds); // freeup esds mem
 #if 0
 	  		  { FILE* f=fopen("esds.dat","wb");
 			  fwrite(&trak->stdata[36],atom_len-8,1,f);

Index: parse_mp4.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/parse_mp4.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- parse_mp4.c	24 Mar 2002 03:07:18 -0000	1.2
+++ parse_mp4.c	24 Mar 2002 06:10:13 -0000	1.3
@@ -29,10 +29,10 @@
   return length;
 }
 
+/* parse the data part of MP4 esds atoms */
 int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds) {
   /* create memory stream from data */
   stream_t *s = new_memory_stream(data, datalen);
-  uint8_t tag;
   uint8_t len;
 
   esds->version = stream_read_char(s);
@@ -42,8 +42,7 @@
       esds->version, esds->flags);
 
   /* get and verify ES_DescrTag */
-  tag = stream_read_char(s);
-  if (tag == MP4ESDescrTag) {
+  if (stream_read_char(s) == MP4ESDescrTag) {
     /* read length */
     if ((len = mp4_read_descr_len(s)) < 5 + 15) {
       freereturn(s,1);
@@ -107,9 +106,38 @@
   mp_msg(MSGT_DEMUX, MP4_DL,
       "ESDS MPEG4 Decoder Specific Descriptor (%dBytes)\n", len);
 
+  /* get and verify SLConfigDescrTag */
+  if(stream_read_char(s) != MP4SLConfigDescrTag) {
+    freereturn(s,1);
+  }
+
+  if((len = mp4_read_descr_len(s)) < 1) {
+    freereturn(s,1);
+  }
+
+  /* Note: SLConfig is usually constant value 2 size 1Byte */
+  esds->SLConfigLen = len;
+  esds->SLConfig = malloc(esds->SLConfigLen);
+  if (esds->SLConfig) {
+    stream_read(s, esds->SLConfig, esds->SLConfigLen);
+  } else {
+    esds->SLConfigLen = 0;
+  }
+  mp_msg(MSGT_DEMUX, MP4_DL,
+      "ESDS MPEG4 Sync Layer Config Descriptor (%dBytes)\n"
+      " -> predefined: %d\n", len, esds->SLConfig[0]);
+
   /* will skip the remainder of the atom */
   freereturn(s,0);
 
+}
+
+/* cleanup all mem occupied by mp4_parse_esds */
+void mp4_free_esds(esds_t *esds) {
+  if(esds->decoderConfig)
+    free(esds->decoderConfig);
+  if(esds->SLConfig)
+    free(esds->SLConfig);
 }
 
 #undef freereturn

Index: parse_mp4.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/parse_mp4.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- parse_mp4.h	24 Mar 2002 02:25:41 -0000	1.1
+++ parse_mp4.h	24 Mar 2002 06:10:13 -0000	1.2
@@ -73,6 +73,7 @@
 } esds_t;
 
 int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds);
+void mp4_free_esds(esds_t *esds); 
 
 #endif /* !__PARSE_MP4_H */
 




More information about the MPlayer-cvslog mailing list