Module: wine Branch: master Commit: 6c1d089a44c8a31037566b56979bca5ec3daaba6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6c1d089a44c8a31037566b5697...
Author: Maarten Lankhorst m.b.lankhorst@gmail.com Date: Thu Mar 13 20:24:58 2008 -0700
quartz: Detect and skip id3v2 header in mpeg splitter.
---
dlls/quartz/mpegsplit.c | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/dlls/quartz/mpegsplit.c b/dlls/quartz/mpegsplit.c index edf39b3..e721eef 100644 --- a/dlls/quartz/mpegsplit.c +++ b/dlls/quartz/mpegsplit.c @@ -337,7 +337,6 @@ static HRESULT MPEGSplitter_init_audio(MPEGSplitterImpl *This, const BYTE *heade mode_ext = ((header[3]>>4)&0x3); emphasis = ((header[3]>>0)&0x3);
- pamt->cbFormat = ((layer==3)? sizeof(MPEGLAYER3WAVEFORMAT) : sizeof(MPEG1WAVEFORMAT)); pamt->pbFormat = CoTaskMemAlloc(pamt->cbFormat); @@ -431,7 +430,7 @@ static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin) ALLOCATOR_PROPERTIES props; HRESULT hr; LONGLONG pos = 0; /* in bytes */ - BYTE header[4]; + BYTE header[10]; int streamtype = 0; LONGLONG total, avail; AM_MEDIA_TYPE amt; @@ -440,15 +439,39 @@ static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin) IAsyncReader_Length(pPin->pReader, &total, &avail); This->EndOfFile = total;
- hr = IAsyncReader_SyncRead(pPin->pReader, pos, 4, (LPVOID)&header[0]); + hr = IAsyncReader_SyncRead(pPin->pReader, pos, 4, header); if (SUCCEEDED(hr)) pos += 4;
+ /* Skip ID3 v2 tag, if any */ + if (SUCCEEDED(hr) && !strncmp("ID3", (char*)header, 3)) + do { + UINT length; + hr = IAsyncReader_SyncRead(pPin->pReader, pos, 6, header + 4); + if (FAILED(hr)) + break; + pos += 6; + TRACE("Found ID3 v2.%d.%d\n", header[3], header[4]); + length = (header[6] & 0x7F) << 21; + length += (header[7] & 0x7F) << 14; + length += (header[8] & 0x7F) << 7; + length += (header[9] & 0x7F); + TRACE("Length: %u\n", length); + pos += length; + + /* Read the real header for the mpeg splitter */ + hr = IAsyncReader_SyncRead(pPin->pReader, pos, 4, header); + if (SUCCEEDED(hr)) + pos += 4; + TRACE("%x:%x:%x:%x\n", header[0], header[1], header[2], header[3]); + } while (0); + while(SUCCEEDED(hr) && !(streamtype=MPEGSplitter_head_check(header))) { + TRACE("%x:%x:%x:%x\n", header[0], header[1], header[2], header[3]); /* No valid header yet; shift by a byte and check again */ memcpy(header, header+1, 3); - hr = IAsyncReader_SyncRead(pPin->pReader, pos++, 1, (LPVOID)&header[3]); + hr = IAsyncReader_SyncRead(pPin->pReader, pos++, 1, header + 3); } if (FAILED(hr)) return hr;