# HG changeset patch # User alex # Date 1008981215 0 # Node ID 65fd971932dccc5b9a799242145f5de0fe7fd47c # Parent 8148193fee93491055bed3cd22b3d51e090f43e1 added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine) diff -r 8148193fee93 -r 65fd971932dc libmpdemux/demux_mov.c --- a/libmpdemux/demux_mov.c Sat Dec 22 00:28:49 2001 +0000 +++ b/libmpdemux/demux_mov.c Sat Dec 22 00:33:35 2001 +0000 @@ -80,6 +80,20 @@ int i,j,s; int last=trak->chunks_size; unsigned int pts=0; + +#if 0 + if (trak->chunks_size <= 0) + { + mp_msg(MSGT_DEMUX, MSGL_WARN, "No chunk offset table, trying to build one!\n"); + + trak->chunks_size = trak->samples_size; + trak->chunks = realloc(trak->chunks, sizeof(mov_chunk_t)*trak->chunks_size); + + for (i=0; i < trak->chunks_size; i++) + trak->chunks[i].pos = -1; + } +#endif + 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); @@ -94,6 +108,18 @@ last=trak->chunkmap[i].first; } +#if 0 + for (i=0; i < trak->chunks_size; i++) + { + /* fixup position */ + if (trak->chunks[i].pos == -1) + if (i > 0) + trak->chunks[i].pos = trak->chunks[i-1].pos + trak->chunks[i-1].size; + else + trak->chunks[i].pos = 0; /* FIXME: set initial pos */ + } +#endif + // calc pts of chunks: s=0; for(j=0;jchunks_size;j++){ @@ -390,6 +416,34 @@ for(i=0;ichunks[i].pos=stream_read_dword(demuxer->stream); break; } + case MOV_FOURCC('c','o','6','4'): { + int temp=stream_read_dword(demuxer->stream); + int len=stream_read_dword(demuxer->stream); + int i; + mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*s64bit chunk offset table! (%d chunks)\n",level,"",len); + // extend array if needed: + if(len>trak->chunks_size){ + trak->chunks=realloc(trak->chunks,sizeof(mov_chunk_t)*len); + trak->chunks_size=len; + } + // read elements: + for(i=0;istream); + int len2=stream_read_dword(demuxer->stream); + + mp_msg(MSGT_DEMUX, MSGL_DBG3, "Chunk #%d: len1=%d, len2=%d\n", i, len1, len2); + +#ifndef _LARGEFILE_SOURCE /* is this right ?! -- alex */ + if (len1) + mp_msg(MSGT_DEMUX, MSGL_WARN, "Chunk %d has got 64bit address, but you've MPlayer compiled without LARGEFILE support!\n", i); + trak->chunks[i].pos = len2; +#else + trak->chunks[i].pos = len1+len2; /* also off_t pos -> on 64bit platform off_t MUST be 64bit */ +#endif + } + break; + } case MOV_FOURCC('s','t','s','s'): { int temp=stream_read_dword(demuxer->stream); int entries=stream_read_dword(demuxer->stream); @@ -501,6 +555,7 @@ } case MOV_TRAK_VIDEO: { sh_video_t* sh=new_sh_video(demuxer,priv->track_db); + int depth = trak->stdata[43+32]; /* requested by Mike Melanson for Apple RLE decoder -- alex */ sh->format=trak->fourcc; if(!sh->fps) sh->fps=trak->timescale; sh->frametime=1.0f/sh->fps; @@ -514,11 +569,11 @@ sh->bih->biWidth=sh->disp_w; sh->bih->biHeight=sh->disp_h; sh->bih->biPlanes=0; - sh->bih->biBitCount=16; + sh->bih->biBitCount=depth; sh->bih->biCompression=trak->fourcc; sh->bih->biSizeImage=sh->bih->biWidth*sh->bih->biHeight; - mp_msg(MSGT_DEMUX, MSGL_INFO, "Image size: %d x %d\n",sh->disp_w,sh->disp_h); + mp_msg(MSGT_DEMUX, MSGL_INFO, "Image size: %d x %d (%dbits)\n",sh->disp_w,sh->disp_h,sh->bih->biBitCount); mp_msg(MSGT_DEMUX, MSGL_INFO, "Fourcc: %.4s Codec: '%.*s'\n",&trak->fourcc,trak->stdata_len-43,trak->stdata+43); if(demuxer->video->id==-1 || demuxer->video->id==priv->track_db){ @@ -818,7 +873,7 @@ } else x=trak->chunks[trak->pos].size; - printf("X = %d\n", x); +// printf("X = %d\n", x); if(trak->stdata_len>=36){ // extended stsd header - works for CBR MP3: x/=(trak->stdata[30]<<8)+trak->stdata[31]; // samples/packet