changeset 2546:c9485365537d

added edit atom (edit list), some comments and typos fixes
author alex
date Mon, 29 Oct 2001 22:40:25 +0000
parents 89e3bf3c0c4e
children 77a3f73c04d5
files libmpdemux/demux_mov.c
diffstat 1 files changed, 47 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mov.c	Mon Oct 29 22:11:40 2001 +0000
+++ b/libmpdemux/demux_mov.c	Mon Oct 29 22:40:25 2001 +0000
@@ -30,7 +30,7 @@
 } mov_sample_t;
 
 typedef struct {
-    unsigned int sample; // number of the first sample in teh chunk
+    unsigned int sample; // number of the first sample in the chunk
     unsigned int size;   // number of samples in the chunk
     int desc;            // for multiple codecs mode - not used
     off_t pos;
@@ -81,6 +81,7 @@
     unsigned int pts=0;
     mp_msg(MSGT_DEMUX, MSGL_HINT, "MOV track: %d chunks, %d samples\n",trak->chunks_size,trak->samples_size);
     mp_msg(MSGT_DEMUX, MSGL_HINT, "pts=%d  scale=%d  time=%5.3f\n",trak->length,trak->timescale,(float)trak->length/(float)trak->timescale);
+
     // process chunkmap:
     i=trak->chunkmap_size;
     while(i>0){
@@ -150,6 +151,7 @@
     mov_track_t* tracks[MOV_MAX_TRACKS];
 } mov_priv_t;
 
+#warning "FIXME - mov support is only working perfectly on Little Endian systems?!"
 #define MOV_FOURCC(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d))
 
 int mov_check_file(demuxer_t* demuxer){
@@ -180,6 +182,7 @@
 	  flags|=2;
 	  break;
 	case MOV_FOURCC('f','r','e','e'):
+	  /* unused, if you edit a mov, you can use space provided by free atoms (redefining it) */
 	  break;
 	case MOV_FOURCC('w','i','d','e'):
 	default:
@@ -341,17 +344,22 @@
 		int ver = (temp << 24);
 		int flags = (temp << 16)|(temp<<8)|temp;
 		int entries=stream_read_dword(demuxer->stream);
+		int i;
+		
+		trak->samplesize=ss;
+		if (ss)
+		{
+		    mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample size table! (fixed ss=%d) (ver:%d,flags:%ld)\n",
+			level,"",ss,ver,flags);
+		    break;
+		}
 		mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample size table! (entries=%d ss=%d) (ver:%d,flags:%ld)\n",
 		    level,"",entries,ss,ver,flags);
-		trak->samplesize=ss;
-		if(!ss){
-		    // variable samplesize
-		    int i;
-		    trak->samples=realloc(trak->samples,sizeof(mov_sample_t)*entries);
-		    trak->samples_size=entries;
-		    for(i=0;i<entries;i++)
-			trak->samples[i].size=stream_read_dword(demuxer->stream);
-		}
+		// variable samplesize
+		trak->samples=realloc(trak->samples,sizeof(mov_sample_t)*entries);
+		trak->samples_size=entries;
+		for(i=0;i<entries;i++)
+		    trak->samples[i].size=stream_read_dword(demuxer->stream);
 		break;
 	    }
 	    case MOV_FOURCC('s','t','c','o'): {
@@ -378,7 +386,8 @@
 		    level, "",entries, ver, flags);
 		trak->keyframes_size=entries;
 		trak->keyframes=malloc(sizeof(unsigned int)*entries);
-		for (i=0;i<entries;i++) trak->keyframes[i]=stream_read_dword(demuxer->stream)-1;
+		for (i=0;i<entries;i++)
+		    trak->keyframes[i]=stream_read_dword(demuxer->stream)-1;
 //		for (i=0;i<entries;i++) printf("%3d: %d\n",i,trak->keyframes[i]);
 		break;
 	    }
@@ -397,6 +406,31 @@
 		lschunks(demuxer,level+1,pos+len,trak);
 		break;
 	    }
+	    case MOV_FOURCC('e','d','t','s'): {
+		mp_msg(MSGT_DEMUX, MSGL_V, "MOV: %*sEdit atom!\n", level, "");
+		lschunks(demuxer,level+1,pos+len,trak);
+		break;
+	    }
+	    case MOV_FOURCC('e','l','s','t'): {
+		int temp=stream_read_dword(demuxer->stream);
+		int entries=stream_read_dword(demuxer->stream);
+		int ver = (temp << 24);
+		int flags = (temp << 16)|(temp<<8)|temp;
+		int i;
+	
+		mp_msg(MSGT_DEMUX, MSGL_V,"MOV: %*sEdit list table (%d entries) (ver:%d,flags:%ld)\n",
+		    level, "",entries, ver, flags);
+#if 0
+		for (i=0;i<entries;i++)
+		{
+		    printf("entry#%d: dur: %ld mtime: %ld mrate: %ld\n",
+			i, stream_read_dword(demuxer->stream),
+			stream_read_dword(demuxer->stream),
+			stream_read_dword(demuxer->stream));
+		}
+#endif
+		break;
+	    }
 	    default:
 		id = bswap_32(id);
 		mp_msg(MSGT_DEMUX,MSGL_V,"MOV: unknown chunk: %.4s %d\n",&id,(int)len);
@@ -761,8 +795,8 @@
 	for(i=0;i<trak->keyframes_size;i++){
 	    if(trak->keyframes[i]>=trak->pos) break;
 	}
-	if(i>0 && 
-	  (trak->keyframes[i]-trak->pos) > (trak->pos-trak->keyframes[i-1])) --i;
+	if(i>0 && (trak->keyframes[i]-trak->pos) > (trak->pos-trak->keyframes[i-1]))
+	  --i;
 	trak->pos=trak->keyframes[i];
 //	printf("nearest keyframe: %d  \n",trak->pos);
     }