Changeset df3af6f13455675fb4815cee000ff17edffebc99
- Timestamp:
- 04/30/08 20:30:13
(4 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1209580213 +0300
- git-parent:
[8d89d74009aca2427c2e013cab55f5c914260faf]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1209580213 +0300
- Message:
Support for RIFF/MIDI files
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rb1cb747 |
rdf3af6f |
|
| 87 | 87 | if (stream_Peek (stream, &peek, 14) < 14) |
|---|
| 88 | 88 | return VLC_EGENERIC; |
|---|
| | 89 | |
|---|
| | 90 | /* Skip RIFF MIDI header if present */ |
|---|
| | 91 | if (!memcmp (peek, "RIFF", 4) && !memcmp (peek + 8, "RMID", 4)) |
|---|
| | 92 | { |
|---|
| | 93 | uint32_t riff_len = GetDWLE (peek + 4); |
|---|
| | 94 | |
|---|
| | 95 | msg_Dbg (p_this, "detected RIFF MIDI file (%u bytes)", |
|---|
| | 96 | (unsigned)riff_len); |
|---|
| | 97 | if ((stream_Read (stream, NULL, 12) < 12)) |
|---|
| | 98 | return VLC_EGENERIC; |
|---|
| | 99 | |
|---|
| | 100 | /* Look for the RIFF data chunk */ |
|---|
| | 101 | for (;;) |
|---|
| | 102 | { |
|---|
| | 103 | char chnk_hdr[8]; |
|---|
| | 104 | uint32_t chnk_len; |
|---|
| | 105 | |
|---|
| | 106 | if ((riff_len < 8) |
|---|
| | 107 | || (stream_Read (stream, chnk_hdr, 8) < 8)) |
|---|
| | 108 | return VLC_EGENERIC; |
|---|
| | 109 | |
|---|
| | 110 | riff_len -= 8; |
|---|
| | 111 | chnk_len = GetDWLE (chnk_hdr + 4); |
|---|
| | 112 | if (riff_len < chnk_len) |
|---|
| | 113 | return VLC_EGENERIC; |
|---|
| | 114 | riff_len -= chnk_len; |
|---|
| | 115 | |
|---|
| | 116 | if (!memcmp (chnk_hdr, "data", 4)) |
|---|
| | 117 | break; /* found! */ |
|---|
| | 118 | |
|---|
| | 119 | if (stream_Read (stream, NULL, chnk_len) < (ssize_t)chnk_len) |
|---|
| | 120 | return VLC_EGENERIC; |
|---|
| | 121 | } |
|---|
| | 122 | |
|---|
| | 123 | /* Read real SMF header. Assume RIFF data chunk length is proper. */ |
|---|
| | 124 | if (stream_Peek (stream, &peek, 14) < 14) |
|---|
| | 125 | return VLC_EGENERIC; |
|---|
| | 126 | } |
|---|
| 89 | 127 | |
|---|
| 90 | 128 | if (memcmp (peek, "MThd\x00\x00\x00\x06", 8)) |
|---|