2009-05-08 21:51:13 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2001-04-23 03:42:17 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2001-08-01 09:14:02 +00:00
|
|
|
#include <unistd.h>
|
2007-06-24 13:09:08 +00:00
|
|
|
#include <inttypes.h>
|
2001-04-23 03:42:17 +00:00
|
|
|
|
2001-10-30 17:03:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-09-22 00:43:14 +00:00
|
|
|
// for avi_stream_id():
|
2007-03-15 18:36:36 +00:00
|
|
|
#include "stream/stream.h"
|
2001-04-23 03:42:17 +00:00
|
|
|
#include "demuxer.h"
|
|
|
|
|
2004-03-17 14:50:37 +00:00
|
|
|
#include "aviheader.h"
|
2004-04-28 10:18:33 +00:00
|
|
|
#include "ms_hdr.h"
|
2010-02-18 00:18:50 +00:00
|
|
|
#include "aviprint.h"
|
2004-03-17 14:50:37 +00:00
|
|
|
|
2001-04-23 03:42:17 +00:00
|
|
|
//#include "codec-cfg.h"
|
|
|
|
//#include "stheader.h"
|
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_avih_flags(MainAVIHeader *h, int verbose_level){
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "MainAVIHeader.dwFlags: (%"PRId32")%s%s%s%s%s%s\n",h->dwFlags,
|
2001-02-24 20:28:24 +00:00
|
|
|
(h->dwFlags&AVIF_HASINDEX)?" HAS_INDEX":"",
|
|
|
|
(h->dwFlags&AVIF_MUSTUSEINDEX)?" MUST_USE_INDEX":"",
|
|
|
|
(h->dwFlags&AVIF_ISINTERLEAVED)?" IS_INTERLEAVED":"",
|
|
|
|
(h->dwFlags&AVIF_TRUSTCKTYPE)?" TRUST_CKTYPE":"",
|
|
|
|
(h->dwFlags&AVIF_WASCAPTUREFILE)?" WAS_CAPTUREFILE":"",
|
|
|
|
(h->dwFlags&AVIF_COPYRIGHTED)?" COPYRIGHTED":""
|
|
|
|
);
|
2001-08-06 23:59:50 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_avih(MainAVIHeader *h, int verbose_level){
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "======= AVI Header =======\n");
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "us/frame: %"PRId32" (fps=%5.3f)\n",h->dwMicroSecPerFrame,1000000.0f/(float)h->dwMicroSecPerFrame);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "max bytes/sec: %"PRId32"\n",h->dwMaxBytesPerSec);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "padding: %"PRId32"\n",h->dwPaddingGranularity);
|
2006-03-27 17:25:41 +00:00
|
|
|
print_avih_flags(h, verbose_level);
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "frames total: %"PRId32" initial: %"PRId32"\n",h->dwTotalFrames,h->dwInitialFrames);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "streams: %"PRId32"\n",h->dwStreams);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Suggested BufferSize: %"PRId32"\n",h->dwSuggestedBufferSize);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Size: %"PRId32" x %"PRId32"\n",h->dwWidth,h->dwHeight);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "==========================\n");
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_strh(AVIStreamHeader *h, int verbose_level){
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "====== STREAM Header =====\n");
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Type: %.4s FCC: %.4s (%X)\n",(char *)&h->fccType,(char *)&h->fccHandler,(unsigned int)h->fccHandler);
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Flags: %"PRId32"\n",h->dwFlags);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Priority: %d Language: %d\n",h->wPriority,h->wLanguage);
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "InitialFrames: %"PRId32"\n",h->dwInitialFrames);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Rate: %"PRId32"/%"PRId32" = %5.3f\n",h->dwRate,h->dwScale,(float)h->dwRate/(float)h->dwScale);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Start: %"PRId32" Len: %"PRId32"\n",h->dwStart,h->dwLength);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Suggested BufferSize: %"PRId32"\n",h->dwSuggestedBufferSize);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Quality %"PRId32"\n",h->dwQuality);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Sample size: %"PRId32"\n",h->dwSampleSize);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "==========================\n");
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_wave_header(WAVEFORMATEX *h, int verbose_level){
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "======= WAVE Format =======\n");
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Format Tag: %d (0x%X)\n",h->wFormatTag,h->wFormatTag);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Channels: %d\n",h->nChannels);
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Samplerate: %"PRId32"\n",h->nSamplesPerSec);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "avg byte/sec: %"PRId32"\n",h->nAvgBytesPerSec);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Block align: %d\n",h->nBlockAlign);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "bits/sample: %d\n",h->wBitsPerSample);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "cbSize: %d\n",h->cbSize);
|
2002-04-19 23:24:13 +00:00
|
|
|
if(h->wFormatTag==0x55 && h->cbSize>=12){
|
2002-08-28 22:45:48 +00:00
|
|
|
MPEGLAYER3WAVEFORMAT* h2=(MPEGLAYER3WAVEFORMAT *)h;
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "mp3.wID=%d\n",h2->wID);
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "mp3.fdwFlags=0x%"PRIX32"\n",h2->fdwFlags);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "mp3.nBlockSize=%d\n",h2->nBlockSize);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "mp3.nFramesPerBlock=%d\n",h2->nFramesPerBlock);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "mp3.nCodecDelay=%d\n",h2->nCodecDelay);
|
2002-04-18 18:01:25 +00:00
|
|
|
}
|
2010-02-22 14:27:32 +00:00
|
|
|
else if (h->wFormatTag == 0xfffe && h->cbSize >= 22) {
|
|
|
|
WAVEFORMATEXTENSIBLE *h2 = (WAVEFORMATEXTENSIBLE *)h;
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "ex.wValidBitsPerSample=%d\n", h2->wValidBitsPerSample);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "ex.dwChannelMask=0x%X\n", h2->dwChannelMask);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "ex.SubFormat=%d (0x%X)\n", h2->SubFormat, h2->SubFormat);
|
|
|
|
}
|
2002-04-21 10:27:29 +00:00
|
|
|
else if (h->cbSize > 0)
|
|
|
|
{
|
|
|
|
int i;
|
2009-01-01 11:41:09 +00:00
|
|
|
uint8_t* p = (uint8_t*)(h + 1);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Unknown extra header dump: ");
|
2002-04-21 10:27:29 +00:00
|
|
|
for (i = 0; i < h->cbSize; i++)
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "[%x] ", p[i]);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "\n");
|
2002-04-21 10:27:29 +00:00
|
|
|
}
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "==========================================================================\n");
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_video_header(BITMAPINFOHEADER *h, int verbose_level){
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "======= VIDEO Format ======\n");
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " biSize %d\n", h->biSize);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " biWidth %d\n", h->biWidth);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " biHeight %d\n", h->biHeight);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " biPlanes %d\n", h->biPlanes);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " biBitCount %d\n", h->biBitCount);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " biCompression %d='%.4s'\n", h->biCompression, (char *)&h->biCompression);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " biSizeImage %d\n", h->biSizeImage);
|
2010-09-12 11:44:42 +00:00
|
|
|
if (h->biSize > sizeof(*h))
|
2003-07-27 22:15:08 +00:00
|
|
|
{
|
|
|
|
int i;
|
2009-01-01 11:41:09 +00:00
|
|
|
uint8_t* p = (uint8_t*)(h + 1);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Unknown extra header dump: ");
|
2010-09-12 11:44:42 +00:00
|
|
|
for (i = 0; i < h->biSize-sizeof(*h); i++)
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "[%x] ", *(p+i));
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "\n");
|
2003-07-27 22:15:08 +00:00
|
|
|
}
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "===========================\n");
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_vprp(VideoPropHeader *vprp, int verbose_level){
|
2004-03-17 14:50:37 +00:00
|
|
|
int i;
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "======= Video Properties Header =======\n");
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Format: %d VideoStandard: %d\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
vprp->VideoFormatToken,vprp->VideoStandard);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "VRefresh: %d HTotal: %d VTotal: %d\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
vprp->dwVerticalRefreshRate, vprp->dwHTotalInT, vprp->dwVTotalInLines);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "FrameAspect: %d:%d Framewidth: %d Frameheight: %d\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
vprp->dwFrameAspectRatio >> 16, vprp->dwFrameAspectRatio & 0xffff,
|
|
|
|
vprp->dwFrameWidthInPixels, vprp->dwFrameHeightInLines);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "Fields: %d\n", vprp->nbFieldPerFrame);
|
2004-03-17 14:50:37 +00:00
|
|
|
for (i=0; i<vprp->nbFieldPerFrame; i++) {
|
|
|
|
VIDEO_FIELD_DESC *vfd = &vprp->FieldInfo[i];
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " == Field %d description ==\n", i);
|
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " CompressedBMHeight: %d CompressedBMWidth: %d\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
vfd->CompressedBMHeight, vfd->CompressedBMWidth);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " ValidBMHeight: %d ValidBMWidth: %d\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
vfd->ValidBMHeight, vfd->ValidBMWidth);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " ValidBMXOffset: %d ValidBMYOffset: %d\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
vfd->ValidBMXOffset, vfd->ValidBMYOffset);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, " VideoXOffsetInT: %d VideoYValidStartLine: %d\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
vfd->VideoXOffsetInT, vfd->VideoYValidStartLine);
|
|
|
|
}
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "=======================================\n");
|
2004-03-17 14:50:37 +00:00
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_index(AVIINDEXENTRY *idx, int idx_size, int verbose_level){
|
2001-02-24 20:28:24 +00:00
|
|
|
int i;
|
2001-08-11 20:37:33 +00:00
|
|
|
unsigned int pos[256];
|
|
|
|
unsigned int num[256];
|
2009-01-01 11:41:09 +00:00
|
|
|
memset(pos, 0, sizeof(pos));
|
|
|
|
memset(num, 0, sizeof(num));
|
2001-04-23 03:42:17 +00:00
|
|
|
for(i=0;i<idx_size;i++){
|
2001-08-11 20:37:33 +00:00
|
|
|
int id=avi_stream_id(idx[i].ckid);
|
|
|
|
if(id<0 || id>255) id=255;
|
2007-06-24 13:09:08 +00:00
|
|
|
mp_msg(MSGT_HEADER, verbose_level, "%5d: %.4s %4X %016"PRIX64" len:%6"PRId32" pos:%7d->%7.3f %7d->%7.3f\n",i,
|
2001-04-23 23:04:02 +00:00
|
|
|
(char *)&idx[i].ckid,
|
2004-03-17 14:50:37 +00:00
|
|
|
(unsigned int)idx[i].dwFlags&0xffff,
|
|
|
|
(uint64_t)AVI_IDX_OFFSET(&idx[i]),
|
2001-04-23 03:42:17 +00:00
|
|
|
// idx[i].dwChunkOffset+demuxer->movi_start,
|
2001-08-11 20:37:33 +00:00
|
|
|
idx[i].dwChunkLength,
|
|
|
|
pos[id],(float)pos[id]/18747.0f,
|
|
|
|
num[id],(float)num[id]/23.976f
|
2001-02-24 20:28:24 +00:00
|
|
|
);
|
2001-08-11 20:37:33 +00:00
|
|
|
pos[id]+=idx[i].dwChunkLength;
|
|
|
|
++num[id];
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_avistdindex_chunk(avistdindex_chunk *h, int verbose_level){
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, "====== AVI Standard Index Header ========\n");
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " FCC (%.4s) dwSize (%d) wLongsPerEntry(%d)\n", h->fcc, h->dwSize, h->wLongsPerEntry);
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " bIndexSubType (%d) bIndexType (%d)\n", h->bIndexSubType, h->bIndexType);
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " nEntriesInUse (%d) dwChunkId (%.4s)\n", h->nEntriesInUse, h->dwChunkId);
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " qwBaseOffset (0x%"PRIX64") dwReserved3 (%d)\n", h->qwBaseOffset, h->dwReserved3);
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, "===========================\n");
|
2004-03-17 14:50:37 +00:00
|
|
|
}
|
2006-03-27 17:25:41 +00:00
|
|
|
void print_avisuperindex_chunk(avisuperindex_chunk *h, int verbose_level){
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, "====== AVI Super Index Header ========\n");
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " FCC (%.4s) dwSize (%d) wLongsPerEntry(%d)\n", h->fcc, h->dwSize, h->wLongsPerEntry);
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " bIndexSubType (%d) bIndexType (%d)\n", h->bIndexSubType, h->bIndexType);
|
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " nEntriesInUse (%d) dwChunkId (%.4s)\n", h->nEntriesInUse, h->dwChunkId);
|
2009-05-13 02:58:57 +00:00
|
|
|
mp_msg (MSGT_HEADER, verbose_level, " dwReserved[0] (%d) dwReserved[1] (%d) dwReserved[2] (%d)\n",
|
2004-03-17 14:50:37 +00:00
|
|
|
h->dwReserved[0], h->dwReserved[1], h->dwReserved[2]);
|
2006-03-27 17:25:41 +00:00
|
|
|
mp_msg (MSGT_HEADER, verbose_level, "===========================\n");
|
2004-03-17 14:50:37 +00:00
|
|
|
}
|