2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 // for avi_stream_id():
27 #include "stream/stream.h"
30 #include "aviheader.h"
34 //#include "codec-cfg.h"
35 //#include "stheader.h"
37 void print_avih_flags(MainAVIHeader
*h
, int verbose_level
){
38 mp_msg(MSGT_HEADER
, verbose_level
, "MainAVIHeader.dwFlags: (%"PRId32
")%s%s%s%s%s%s\n",h
->dwFlags
,
39 (h
->dwFlags
&AVIF_HASINDEX
)?" HAS_INDEX":"",
40 (h
->dwFlags
&AVIF_MUSTUSEINDEX
)?" MUST_USE_INDEX":"",
41 (h
->dwFlags
&AVIF_ISINTERLEAVED
)?" IS_INTERLEAVED":"",
42 (h
->dwFlags
&AVIF_TRUSTCKTYPE
)?" TRUST_CKTYPE":"",
43 (h
->dwFlags
&AVIF_WASCAPTUREFILE
)?" WAS_CAPTUREFILE":"",
44 (h
->dwFlags
&AVIF_COPYRIGHTED
)?" COPYRIGHTED":""
48 void print_avih(MainAVIHeader
*h
, int verbose_level
){
49 mp_msg(MSGT_HEADER
, verbose_level
, "======= AVI Header =======\n");
50 mp_msg(MSGT_HEADER
, verbose_level
, "us/frame: %"PRId32
" (fps=%5.3f)\n",h
->dwMicroSecPerFrame
,1000000.0f
/(float)h
->dwMicroSecPerFrame
);
51 mp_msg(MSGT_HEADER
, verbose_level
, "max bytes/sec: %"PRId32
"\n",h
->dwMaxBytesPerSec
);
52 mp_msg(MSGT_HEADER
, verbose_level
, "padding: %"PRId32
"\n",h
->dwPaddingGranularity
);
53 print_avih_flags(h
, verbose_level
);
54 mp_msg(MSGT_HEADER
, verbose_level
, "frames total: %"PRId32
" initial: %"PRId32
"\n",h
->dwTotalFrames
,h
->dwInitialFrames
);
55 mp_msg(MSGT_HEADER
, verbose_level
, "streams: %"PRId32
"\n",h
->dwStreams
);
56 mp_msg(MSGT_HEADER
, verbose_level
, "Suggested BufferSize: %"PRId32
"\n",h
->dwSuggestedBufferSize
);
57 mp_msg(MSGT_HEADER
, verbose_level
, "Size: %"PRId32
" x %"PRId32
"\n",h
->dwWidth
,h
->dwHeight
);
58 mp_msg(MSGT_HEADER
, verbose_level
, "==========================\n");
61 void print_strh(AVIStreamHeader
*h
, int verbose_level
){
62 mp_msg(MSGT_HEADER
, verbose_level
, "====== STREAM Header =====\n");
63 mp_msg(MSGT_HEADER
, verbose_level
, "Type: %.4s FCC: %.4s (%X)\n",(char *)&h
->fccType
,(char *)&h
->fccHandler
,(unsigned int)h
->fccHandler
);
64 mp_msg(MSGT_HEADER
, verbose_level
, "Flags: %"PRId32
"\n",h
->dwFlags
);
65 mp_msg(MSGT_HEADER
, verbose_level
, "Priority: %d Language: %d\n",h
->wPriority
,h
->wLanguage
);
66 mp_msg(MSGT_HEADER
, verbose_level
, "InitialFrames: %"PRId32
"\n",h
->dwInitialFrames
);
67 mp_msg(MSGT_HEADER
, verbose_level
, "Rate: %"PRId32
"/%"PRId32
" = %5.3f\n",h
->dwRate
,h
->dwScale
,(float)h
->dwRate
/(float)h
->dwScale
);
68 mp_msg(MSGT_HEADER
, verbose_level
, "Start: %"PRId32
" Len: %"PRId32
"\n",h
->dwStart
,h
->dwLength
);
69 mp_msg(MSGT_HEADER
, verbose_level
, "Suggested BufferSize: %"PRId32
"\n",h
->dwSuggestedBufferSize
);
70 mp_msg(MSGT_HEADER
, verbose_level
, "Quality %"PRId32
"\n",h
->dwQuality
);
71 mp_msg(MSGT_HEADER
, verbose_level
, "Sample size: %"PRId32
"\n",h
->dwSampleSize
);
72 mp_msg(MSGT_HEADER
, verbose_level
, "==========================\n");
75 void print_wave_header(WAVEFORMATEX
*h
, int verbose_level
){
76 mp_msg(MSGT_HEADER
, verbose_level
, "======= WAVE Format =======\n");
77 mp_msg(MSGT_HEADER
, verbose_level
, "Format Tag: %d (0x%X)\n",h
->wFormatTag
,h
->wFormatTag
);
78 mp_msg(MSGT_HEADER
, verbose_level
, "Channels: %d\n",h
->nChannels
);
79 mp_msg(MSGT_HEADER
, verbose_level
, "Samplerate: %"PRId32
"\n",h
->nSamplesPerSec
);
80 mp_msg(MSGT_HEADER
, verbose_level
, "avg byte/sec: %"PRId32
"\n",h
->nAvgBytesPerSec
);
81 mp_msg(MSGT_HEADER
, verbose_level
, "Block align: %d\n",h
->nBlockAlign
);
82 mp_msg(MSGT_HEADER
, verbose_level
, "bits/sample: %d\n",h
->wBitsPerSample
);
83 mp_msg(MSGT_HEADER
, verbose_level
, "cbSize: %d\n",h
->cbSize
);
84 if(h
->wFormatTag
==0x55 && h
->cbSize
>=12){
85 MPEGLAYER3WAVEFORMAT
* h2
=(MPEGLAYER3WAVEFORMAT
*)h
;
86 mp_msg(MSGT_HEADER
, verbose_level
, "mp3.wID=%d\n",h2
->wID
);
87 mp_msg(MSGT_HEADER
, verbose_level
, "mp3.fdwFlags=0x%"PRIX32
"\n",h2
->fdwFlags
);
88 mp_msg(MSGT_HEADER
, verbose_level
, "mp3.nBlockSize=%d\n",h2
->nBlockSize
);
89 mp_msg(MSGT_HEADER
, verbose_level
, "mp3.nFramesPerBlock=%d\n",h2
->nFramesPerBlock
);
90 mp_msg(MSGT_HEADER
, verbose_level
, "mp3.nCodecDelay=%d\n",h2
->nCodecDelay
);
92 else if (h
->wFormatTag
== 0xfffe && h
->cbSize
>= 22) {
93 WAVEFORMATEXTENSIBLE
*h2
= (WAVEFORMATEXTENSIBLE
*)h
;
94 mp_msg(MSGT_HEADER
, verbose_level
, "ex.wValidBitsPerSample=%d\n", h2
->wValidBitsPerSample
);
95 mp_msg(MSGT_HEADER
, verbose_level
, "ex.dwChannelMask=0x%X\n", h2
->dwChannelMask
);
96 mp_msg(MSGT_HEADER
, verbose_level
, "ex.SubFormat=%d (0x%X)\n", h2
->SubFormat
, h2
->SubFormat
);
98 else if (h
->cbSize
> 0)
101 uint8_t* p
= (uint8_t*)(h
+ 1);
102 mp_msg(MSGT_HEADER
, verbose_level
, "Unknown extra header dump: ");
103 for (i
= 0; i
< h
->cbSize
; i
++)
104 mp_msg(MSGT_HEADER
, verbose_level
, "[%x] ", p
[i
]);
105 mp_msg(MSGT_HEADER
, verbose_level
, "\n");
107 mp_msg(MSGT_HEADER
, verbose_level
, "==========================================================================\n");
111 void print_video_header(BITMAPINFOHEADER
*h
, int verbose_level
){
112 mp_msg(MSGT_HEADER
, verbose_level
, "======= VIDEO Format ======\n");
113 mp_msg(MSGT_HEADER
, verbose_level
, " biSize %d\n", h
->biSize
);
114 mp_msg(MSGT_HEADER
, verbose_level
, " biWidth %d\n", h
->biWidth
);
115 mp_msg(MSGT_HEADER
, verbose_level
, " biHeight %d\n", h
->biHeight
);
116 mp_msg(MSGT_HEADER
, verbose_level
, " biPlanes %d\n", h
->biPlanes
);
117 mp_msg(MSGT_HEADER
, verbose_level
, " biBitCount %d\n", h
->biBitCount
);
118 mp_msg(MSGT_HEADER
, verbose_level
, " biCompression %d='%.4s'\n", h
->biCompression
, (char *)&h
->biCompression
);
119 mp_msg(MSGT_HEADER
, verbose_level
, " biSizeImage %d\n", h
->biSizeImage
);
120 if (h
->biSize
> sizeof(*h
))
123 uint8_t* p
= (uint8_t*)(h
+ 1);
124 mp_msg(MSGT_HEADER
, verbose_level
, "Unknown extra header dump: ");
125 for (i
= 0; i
< h
->biSize
-sizeof(*h
); i
++)
126 mp_msg(MSGT_HEADER
, verbose_level
, "[%x] ", *(p
+i
));
127 mp_msg(MSGT_HEADER
, verbose_level
, "\n");
129 mp_msg(MSGT_HEADER
, verbose_level
, "===========================\n");
132 void print_vprp(VideoPropHeader
*vprp
, int verbose_level
){
134 mp_msg(MSGT_HEADER
, verbose_level
, "======= Video Properties Header =======\n");
135 mp_msg(MSGT_HEADER
, verbose_level
, "Format: %d VideoStandard: %d\n",
136 vprp
->VideoFormatToken
,vprp
->VideoStandard
);
137 mp_msg(MSGT_HEADER
, verbose_level
, "VRefresh: %d HTotal: %d VTotal: %d\n",
138 vprp
->dwVerticalRefreshRate
, vprp
->dwHTotalInT
, vprp
->dwVTotalInLines
);
139 mp_msg(MSGT_HEADER
, verbose_level
, "FrameAspect: %d:%d Framewidth: %d Frameheight: %d\n",
140 vprp
->dwFrameAspectRatio
>> 16, vprp
->dwFrameAspectRatio
& 0xffff,
141 vprp
->dwFrameWidthInPixels
, vprp
->dwFrameHeightInLines
);
142 mp_msg(MSGT_HEADER
, verbose_level
, "Fields: %d\n", vprp
->nbFieldPerFrame
);
143 for (i
=0; i
<vprp
->nbFieldPerFrame
; i
++) {
144 VIDEO_FIELD_DESC
*vfd
= &vprp
->FieldInfo
[i
];
145 mp_msg(MSGT_HEADER
, verbose_level
, " == Field %d description ==\n", i
);
146 mp_msg(MSGT_HEADER
, verbose_level
, " CompressedBMHeight: %d CompressedBMWidth: %d\n",
147 vfd
->CompressedBMHeight
, vfd
->CompressedBMWidth
);
148 mp_msg(MSGT_HEADER
, verbose_level
, " ValidBMHeight: %d ValidBMWidth: %d\n",
149 vfd
->ValidBMHeight
, vfd
->ValidBMWidth
);
150 mp_msg(MSGT_HEADER
, verbose_level
, " ValidBMXOffset: %d ValidBMYOffset: %d\n",
151 vfd
->ValidBMXOffset
, vfd
->ValidBMYOffset
);
152 mp_msg(MSGT_HEADER
, verbose_level
, " VideoXOffsetInT: %d VideoYValidStartLine: %d\n",
153 vfd
->VideoXOffsetInT
, vfd
->VideoYValidStartLine
);
155 mp_msg(MSGT_HEADER
, verbose_level
, "=======================================\n");
158 void print_index(AVIINDEXENTRY
*idx
, int idx_size
, int verbose_level
){
160 unsigned int pos
[256];
161 unsigned int num
[256];
162 memset(pos
, 0, sizeof(pos
));
163 memset(num
, 0, sizeof(num
));
164 for(i
=0;i
<idx_size
;i
++){
165 int id
=avi_stream_id(idx
[i
].ckid
);
166 if(id
<0 || id
>255) id
=255;
167 mp_msg(MSGT_HEADER
, verbose_level
, "%5d: %.4s %4X %016"PRIX64
" len:%6"PRId32
" pos:%7d->%7.3f %7d->%7.3f\n",i
,
168 (char *)&idx
[i
].ckid
,
169 (unsigned int)idx
[i
].dwFlags
&0xffff,
170 (uint64_t)AVI_IDX_OFFSET(&idx
[i
]),
171 // idx[i].dwChunkOffset+demuxer->movi_start,
172 idx
[i
].dwChunkLength
,
173 pos
[id
],(float)pos
[id
]/18747.0f
,
174 num
[id
],(float)num
[id
]/23.976f
176 pos
[id
]+=idx
[i
].dwChunkLength
;
181 void print_avistdindex_chunk(avistdindex_chunk
*h
, int verbose_level
){
182 mp_msg (MSGT_HEADER
, verbose_level
, "====== AVI Standard Index Header ========\n");
183 mp_msg (MSGT_HEADER
, verbose_level
, " FCC (%.4s) dwSize (%d) wLongsPerEntry(%d)\n", h
->fcc
, h
->dwSize
, h
->wLongsPerEntry
);
184 mp_msg (MSGT_HEADER
, verbose_level
, " bIndexSubType (%d) bIndexType (%d)\n", h
->bIndexSubType
, h
->bIndexType
);
185 mp_msg (MSGT_HEADER
, verbose_level
, " nEntriesInUse (%d) dwChunkId (%.4s)\n", h
->nEntriesInUse
, h
->dwChunkId
);
186 mp_msg (MSGT_HEADER
, verbose_level
, " qwBaseOffset (0x%"PRIX64
") dwReserved3 (%d)\n", h
->qwBaseOffset
, h
->dwReserved3
);
187 mp_msg (MSGT_HEADER
, verbose_level
, "===========================\n");
189 void print_avisuperindex_chunk(avisuperindex_chunk
*h
, int verbose_level
){
190 mp_msg (MSGT_HEADER
, verbose_level
, "====== AVI Super Index Header ========\n");
191 mp_msg (MSGT_HEADER
, verbose_level
, " FCC (%.4s) dwSize (%d) wLongsPerEntry(%d)\n", h
->fcc
, h
->dwSize
, h
->wLongsPerEntry
);
192 mp_msg (MSGT_HEADER
, verbose_level
, " bIndexSubType (%d) bIndexType (%d)\n", h
->bIndexSubType
, h
->bIndexType
);
193 mp_msg (MSGT_HEADER
, verbose_level
, " nEntriesInUse (%d) dwChunkId (%.4s)\n", h
->nEntriesInUse
, h
->dwChunkId
);
194 mp_msg (MSGT_HEADER
, verbose_level
, " dwReserved[0] (%d) dwReserved[1] (%d) dwReserved[2] (%d)\n",
195 h
->dwReserved
[0], h
->dwReserved
[1], h
->dwReserved
[2]);
196 mp_msg (MSGT_HEADER
, verbose_level
, "===========================\n");