Mercurial > mplayer.hg
annotate libmpdemux/aviheader.h @ 11619:179138947307
This patch contains bugfixes for the esd audio output driver that I
uncovered while trying to send sound to a remote esd server over a
wireless (11 mbs, just enough to handle to sound) link.
First, the sound was full "ticking" sounds. I found a bug that
prevented the "send the remainder of this block" code from ever being
called - so large chunks of audio were simply being ignored. Fixing
this bug removed the "ticking" from audio streams.
Fixing this bug, however, uncovered another problem - when the socket
buffer was full, doing a blocking write to finish the buffer would take
far too long and would turn video into a chunky mess. I'd imagine this
blocking write would be fine for an audio-only stream, but it turns out
to hold up the video far too much.
The solution in this patch is to write as much data as possible to the
socket, and then return as soon as possible, reporting the number of
bytes actually written accurately back to mplayer. I've tested it on
both local and remote esd servers, and it works well.
Patch by Benjamin Osheroff <ben@gimbo.net>
author | attila |
---|---|
date | Wed, 10 Dec 2003 12:19:13 +0000 |
parents | ae5a2ae1c349 |
children | 846ed866f86c |
rev | line source |
---|---|
1343 | 1 #ifndef _aviheader_h |
2 #define _aviheader_h | |
3 | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
4 //#include "config.h" /* get correct definition WORDS_BIGENDIAN */ |
1343 | 5 #include "bswap.h" |
6 | |
7 /* | |
8 * Some macros to swap little endian structures read from an AVI file | |
9 * into machine endian format | |
10 */ | |
11 #ifdef WORDS_BIGENDIAN | |
12 #define le2me_MainAVIHeader(h) { \ | |
13 (h)->dwMicroSecPerFrame = le2me_32((h)->dwMicroSecPerFrame); \ | |
14 (h)->dwMaxBytesPerSec = le2me_32((h)->dwMaxBytesPerSec); \ | |
15 (h)->dwPaddingGranularity = le2me_32((h)->dwPaddingGranularity); \ | |
16 (h)->dwFlags = le2me_32((h)->dwFlags); \ | |
17 (h)->dwTotalFrames = le2me_32((h)->dwTotalFrames); \ | |
18 (h)->dwInitialFrames = le2me_32((h)->dwInitialFrames); \ | |
19 (h)->dwStreams = le2me_32((h)->dwStreams); \ | |
20 (h)->dwSuggestedBufferSize = le2me_32((h)->dwSuggestedBufferSize); \ | |
21 (h)->dwWidth = le2me_32((h)->dwWidth); \ | |
22 (h)->dwHeight = le2me_32((h)->dwHeight); \ | |
23 } | |
24 | |
25 #define le2me_AVIStreamHeader(h) { \ | |
26 (h)->fccType = le2me_32((h)->fccType); \ | |
27 (h)->fccHandler = le2me_32((h)->fccHandler); \ | |
28 (h)->dwFlags = le2me_32((h)->dwFlags); \ | |
29 (h)->wPriority = le2me_16((h)->wPriority); \ | |
30 (h)->wLanguage = le2me_16((h)->wLanguage); \ | |
31 (h)->dwInitialFrames = le2me_32((h)->dwInitialFrames); \ | |
32 (h)->dwScale = le2me_32((h)->dwScale); \ | |
33 (h)->dwRate = le2me_32((h)->dwRate); \ | |
34 (h)->dwStart = le2me_32((h)->dwStart); \ | |
35 (h)->dwLength = le2me_32((h)->dwLength); \ | |
36 (h)->dwSuggestedBufferSize = le2me_32((h)->dwSuggestedBufferSize); \ | |
37 (h)->dwQuality = le2me_32((h)->dwQuality); \ | |
38 (h)->dwSampleSize = le2me_32((h)->dwSampleSize); \ | |
39 le2me_RECT(&(h)->rcFrame); \ | |
40 } | |
41 #define le2me_RECT(h) { \ | |
42 (h)->left = le2me_16((h)->left); \ | |
43 (h)->top = le2me_16((h)->top); \ | |
44 (h)->right = le2me_16((h)->right); \ | |
45 (h)->bottom = le2me_16((h)->bottom); \ | |
46 } | |
47 #define le2me_BITMAPINFOHEADER(h) { \ | |
48 (h)->biSize = le2me_32((h)->biSize); \ | |
49 (h)->biWidth = le2me_32((h)->biWidth); \ | |
50 (h)->biHeight = le2me_32((h)->biHeight); \ | |
51 (h)->biPlanes = le2me_16((h)->biPlanes); \ | |
52 (h)->biBitCount = le2me_16((h)->biBitCount); \ | |
53 (h)->biCompression = le2me_32((h)->biCompression); \ | |
54 (h)->biSizeImage = le2me_32((h)->biSizeImage); \ | |
55 (h)->biXPelsPerMeter = le2me_32((h)->biXPelsPerMeter); \ | |
56 (h)->biYPelsPerMeter = le2me_32((h)->biYPelsPerMeter); \ | |
57 (h)->biClrUsed = le2me_32((h)->biClrUsed); \ | |
58 (h)->biClrImportant = le2me_32((h)->biClrImportant); \ | |
59 } | |
60 #define le2me_WAVEFORMATEX(h) { \ | |
61 (h)->wFormatTag = le2me_16((h)->wFormatTag); \ | |
62 (h)->nChannels = le2me_16((h)->nChannels); \ | |
63 (h)->nSamplesPerSec = le2me_32((h)->nSamplesPerSec); \ | |
64 (h)->nAvgBytesPerSec = le2me_32((h)->nAvgBytesPerSec); \ | |
65 (h)->nBlockAlign = le2me_16((h)->nBlockAlign); \ | |
66 (h)->wBitsPerSample = le2me_16((h)->wBitsPerSample); \ | |
67 (h)->cbSize = le2me_16((h)->cbSize); \ | |
68 } | |
69 #define le2me_AVIINDEXENTRY(h) { \ | |
70 (h)->ckid = le2me_32((h)->ckid); \ | |
71 (h)->dwFlags = le2me_32((h)->dwFlags); \ | |
72 (h)->dwChunkOffset = le2me_32((h)->dwChunkOffset); \ | |
73 (h)->dwChunkLength = le2me_32((h)->dwChunkLength); \ | |
74 } | |
75 #else | |
76 #define le2me_MainAVIHeader(h) /**/ | |
77 #define le2me_AVIStreamHeader(h) /**/ | |
78 #define le2me_RECT(h) /**/ | |
79 #define le2me_BITMAPINFOHEADER(h) /**/ | |
80 #define le2me_WAVEFORMATEX(h) /**/ | |
81 #define le2me_AVIINDEXENTRY(h) /**/ | |
82 #endif | |
83 | |
84 | |
85 #endif | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
86 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
87 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
88 typedef struct { |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
89 // index stuff: |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
90 void* idx; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
91 int idx_size; |
6056
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
2330
diff
changeset
|
92 off_t idx_pos; |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
2330
diff
changeset
|
93 off_t idx_pos_a; |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
2330
diff
changeset
|
94 off_t idx_pos_v; |
f980563afdbc
big (>2GB) AVI files support - patch by Wolfram Gloger <wg@malloc.de>
arpi
parents:
2330
diff
changeset
|
95 off_t idx_offset; // ennyit kell hozzaadni az index offset ertekekhez |
8030
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
6056
diff
changeset
|
96 // bps-based PTS stuff: |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
6056
diff
changeset
|
97 int video_pack_no; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
6056
diff
changeset
|
98 int audio_block_size; |
2b39ff3860b7
cleanup of .AVI timestamp calculation (ugly hack from mplayer.c removed,
arpi
parents:
6056
diff
changeset
|
99 off_t audio_block_no; |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
100 // interleaved PTS stuff: |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
101 int skip_video_frames; |
2330 | 102 int audio_streams; |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
103 float avi_audio_pts; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
104 float avi_video_pts; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
105 float pts_correction; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
106 unsigned int pts_corr_bytes; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
107 unsigned char pts_corrected; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
108 unsigned char pts_has_video; |
8208
ae5a2ae1c349
demuxer_control(), percent position and time length query implemented in
arpi
parents:
8030
diff
changeset
|
109 unsigned int numberofframes; |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
110 } avi_priv_t; |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
111 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1343
diff
changeset
|
112 #define AVI_PRIV ((avi_priv_t*)(demuxer->priv)) |