quartz: Partially implement the MPEG 1 Stream Splitter filter [try
2]
Chris Robinson
chris.kcat at gmail.com
Wed Apr 18 05:55:53 CDT 2007
Now using bitfields and being cautious about big endian machines, as suggested
by Dmitry.
-------------- next part --------------
From b2d6d82cb0ec8896f8588cedff2ba2bdf4091804 Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat at gmail.com>
Date: Wed, 18 Apr 2007 03:50:32 -0700
Subject: [PATCH] quartz: Partially implement the MPEG 1 Stream Splitter filter
---
dlls/quartz/Makefile.in | 1 +
dlls/quartz/main.c | 1 +
dlls/quartz/mpegsplit.c | 561 ++++++++++++++++++++++++++++++++++++++++++
dlls/quartz/quartz_private.h | 1 +
dlls/quartz/regsvr.c | 33 +++
5 files changed, 597 insertions(+), 0 deletions(-)
diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in
index b9870ed..8f714cd 100644
--- a/dlls/quartz/Makefile.in
+++ b/dlls/quartz/Makefile.in
@@ -23,6 +23,7 @@ C_SRCS = \
filtermapper.c \
main.c \
memallocator.c \
+ mpegsplit.c \
parser.c \
pin.c \
regsvr.c \
diff --git a/dlls/quartz/main.c b/dlls/quartz/main.c
index 4c3eb9d..1e9e892 100644
--- a/dlls/quartz/main.c
+++ b/dlls/quartz/main.c
@@ -67,6 +67,7 @@ static const struct object_creation_info object_creation[] =
{ &CLSID_AsyncReader, AsyncReader_create },
{ &CLSID_MemoryAllocator, StdMemAllocator_create },
{ &CLSID_AviSplitter, AVISplitter_create },
+ { &CLSID_MPEG1Splitter, MPEGSplitter_create },
{ &CLSID_VideoRenderer, VideoRenderer_create },
{ &CLSID_DSoundRender, DSoundRender_create },
{ &CLSID_AVIDec, AVIDec_create },
diff --git a/dlls/quartz/mpegsplit.c b/dlls/quartz/mpegsplit.c
new file mode 100644
index 0000000..ebe71e0
--- /dev/null
+++ b/dlls/quartz/mpegsplit.c
@@ -0,0 +1,561 @@
+/*
+ * MPEG Splitter Filter
+ *
+ * Copyright 2003 Robert Shearman
+ * Copyright 2004-2005 Christian Costa
+ * Copyright 2007 Chris Robinson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "quartz_private.h"
+#include "control_private.h"
+#include "pin.h"
+
+#include "uuids.h"
+#include "mmreg.h"
+#include "vfwmsgs.h"
+#include "mmsystem.h"
+
+#include "winternl.h"
+
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+#include <math.h>
+#include <assert.h>
+
+#include "parser.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(quartz);
+
+#define SEQUENCE_HEADER_CODE 0xB3
+#define PACK_START_CODE 0xBA
+
+#define SYSTEM_START_CODE 0xBB
+#define AUDIO_ELEMENTARY_STREAM 0xC0
+#define VIDEO_ELEMENTARY_STREAM 0xE0
+
+#define MPEG_SYSTEM_HEADER 3
+#define MPEG_VIDEO_HEADER 2
+#define MPEG_AUDIO_HEADER 1
+#define MPEG_NO_HEADER 0
+
+
+#ifdef WORDS_BIGENDIAN
+#define GET_BE_DWORD(x) (x)
+#define GET_MSB_PTR(x) ((BYTE*)(x) + 3)
+#else
+#define GET_BE_DWORD(x) RtlUlongByteSwap(x)
+#define GET_MSB_PTR(x) ((BYTE*)(x))
+#endif
+
+
+typedef struct MPEGSplitterImpl
+{
+ ParserImpl Parser;
+ IMediaSample *pCurrentSample;
+ LONGLONG EndOfFile;
+} MPEGSplitterImpl;
+
+typedef union {
+ struct {
+ DWORD code : 8;
+ DWORD marker : 24; /* Must be 1 */
+ } s;
+
+ struct {
+ DWORD emphasis : 2;
+ DWORD original : 1;
+ DWORD copyright : 1;
+ DWORD mode_ext : 2;
+ DWORD mode : 2;
+ DWORD extension : 1;
+ DWORD padding : 1;
+ DWORD freq_idx : 2;
+ DWORD br_idx : 4;
+ DWORD no_crc : 1;
+ DWORD inv_layer : 2;
+ DWORD no_lsf : 1;
+ DWORD mpeg1 : 1;
+ DWORD marker : 11; /* Must be 0x7ff */
+ } a;
+
+ DWORD value;
+} uHeader;
+
+static int head_check(uHeader head)
+{
+ /* If this is a possible start code, check for a system or video header */
+ if (head.s.marker == 1)
+ {
+ /* Check if we got a system or elementary stream start code */
+ if (head.s.code == PACK_START_CODE ||
+ head.s.code == VIDEO_ELEMENTARY_STREAM ||
+ head.s.code == AUDIO_ELEMENTARY_STREAM)
+ return MPEG_SYSTEM_HEADER;
+
+ /* Check for a MPEG video sequence start code */
+ if (head.s.code == SEQUENCE_HEADER_CODE)
+ return MPEG_VIDEO_HEADER;
+ }
+
+ /* This should give a good guess if we have an MPEG audio header */
+ if(head.a.marker == 0x7ff && head.a.inv_layer != 0 &&
+ head.a.br_idx != 0xf && head.a.freq_idx != 0x3)
+ return MPEG_AUDIO_HEADER;
+
+ /* Nothing yet.. */
+ return MPEG_NO_HEADER;
+}
+
+
+static HRESULT MPEGSplitter_process_sample(LPVOID iface, IMediaSample * pSample)
+{
+ MPEGSplitterImpl *This = (MPEGSplitterImpl*)iface;
+ LPBYTE pbSrcStream = NULL;
+ DWORD cbSrcStream = 0;
+ DWORD used_bytes = 0;
+ REFERENCE_TIME tStart, tStop;
+ HRESULT hr;
+ BYTE *pbDstStream;
+ DWORD cbDstStream;
+ long remaining_bytes = 0;
+ Parser_OutputPin * pOutputPin;
+ DWORD bytes_written = 0;
+
+ pOutputPin = (Parser_OutputPin*)This->Parser.ppPins[1];
+
+ hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
+ if (SUCCEEDED(hr))
+ {
+ cbSrcStream = IMediaSample_GetActualDataLength(pSample);
+ hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
+ }
+
+ /* trace removed for performance reasons */
+ /* TRACE("(%p), %llu -> %llu\n", pSample, tStart, tStop); */
+
+ if (This->pCurrentSample)
+ bytes_written = IMediaSample_GetActualDataLength(This->pCurrentSample);
+
+ while (hr == S_OK && used_bytes < cbSrcStream)
+ {
+ remaining_bytes = (long)(This->EndOfFile - BYTES_FROM_MEDIATIME(tStart) - used_bytes);
+ if (remaining_bytes <= 0)
+ break;
+
+ if (!This->pCurrentSample)
+ {
+ /* cache media sample until it is ready to be despatched
+ * (i.e. we reach the end of the chunk) */
+ hr = OutputPin_GetDeliveryBuffer(&pOutputPin->pin, &This->pCurrentSample, NULL, NULL, 0);
+ if (FAILED(hr))
+ {
+ TRACE("Skipping sending sample due to error (%x)\n", hr);
+ This->pCurrentSample = NULL;
+ break;
+ }
+
+ IMediaSample_SetTime(This->pCurrentSample, NULL, NULL);
+ hr = IMediaSample_SetActualDataLength(This->pCurrentSample, 0);
+ assert(hr == S_OK);
+ bytes_written = 0;
+ }
+
+ hr = IMediaSample_GetPointer(This->pCurrentSample, &pbDstStream);
+ if (SUCCEEDED(hr))
+ {
+ cbDstStream = IMediaSample_GetSize(This->pCurrentSample);
+ remaining_bytes = min(remaining_bytes, (long)(cbDstStream - bytes_written));
+
+ assert(remaining_bytes >= 0);
+
+ /* trace removed for performance reasons */
+ /* TRACE("remaining_bytes: %d, cbSrcStream: 0x%x\n", remaining_bytes, cbSrcStream); */
+ }
+
+ if (remaining_bytes <= (long)(cbSrcStream-used_bytes))
+ {
+ if (SUCCEEDED(hr))
+ {
+ memcpy(pbDstStream + bytes_written, pbSrcStream + used_bytes, remaining_bytes);
+ bytes_written += remaining_bytes;
+
+ hr = IMediaSample_SetActualDataLength(This->pCurrentSample, bytes_written);
+ assert(hr == S_OK);
+
+ used_bytes += remaining_bytes;
+ }
+
+ if (SUCCEEDED(hr))
+ {
+ REFERENCE_TIME tMPEGStart, tMPEGStop;
+
+ IMediaSample_SetSyncPoint(This->pCurrentSample, TRUE);
+
+ pOutputPin->dwSamplesProcessed = (BYTES_FROM_MEDIATIME(tStart)+used_bytes-bytes_written) / pOutputPin->dwSampleSize;
+ tMPEGStart = (LONGLONG)ceil(10000000.0 * (double)pOutputPin->dwSamplesProcessed * (double)bytes_written / ((double)pOutputPin->dwSampleSize * pOutputPin->fSamplesPerSec));
+
+ pOutputPin->dwSamplesProcessed += bytes_written / pOutputPin->dwSampleSize;
+ tMPEGStop = (LONGLONG)ceil(10000000.0 * (double)pOutputPin->dwSamplesProcessed * (double)bytes_written / ((float)pOutputPin->dwSampleSize * pOutputPin->fSamplesPerSec));
+
+ IMediaSample_SetTime(This->pCurrentSample, &tMPEGStart, &tMPEGStop);
+
+ hr = OutputPin_SendSample(&pOutputPin->pin, This->pCurrentSample);
+ if (FAILED(hr))
+ WARN("Error sending sample (%x)\n", hr);
+ }
+
+ if (This->pCurrentSample)
+ IMediaSample_Release(This->pCurrentSample);
+ This->pCurrentSample = NULL;
+ }
+ else
+ {
+ if (SUCCEEDED(hr))
+ {
+ memcpy(pbDstStream + bytes_written, pbSrcStream + used_bytes, cbSrcStream - used_bytes);
+ bytes_written += cbSrcStream - used_bytes;
+ IMediaSample_SetActualDataLength(This->pCurrentSample, bytes_written);
+
+ used_bytes += cbSrcStream - used_bytes;
+ }
+ }
+ }
+
+ if (BYTES_FROM_MEDIATIME(tStop) >= This->EndOfFile)
+ {
+ int i;
+
+ TRACE("End of file reached (%d out of %d bytes used)\n", used_bytes, cbSrcStream);
+
+ if (This->pCurrentSample)
+ {
+ /* Make sure the last bit of data, if any, is sent */
+ if (IMediaSample_GetActualDataLength(This->pCurrentSample) > 0)
+ {
+ REFERENCE_TIME tMPEGStart, tMPEGStop;
+
+ IMediaSample_SetSyncPoint(This->pCurrentSample, TRUE);
+
+ pOutputPin->dwSamplesProcessed = (BYTES_FROM_MEDIATIME(tStart)+used_bytes-bytes_written) / pOutputPin->dwSampleSize;
+ tMPEGStart = (LONGLONG)ceil(10000000.0 * (double)pOutputPin->dwSamplesProcessed * (double)bytes_written / ((double)pOutputPin->dwSampleSize * pOutputPin->fSamplesPerSec));
+
+ pOutputPin->dwSamplesProcessed += bytes_written / pOutputPin->dwSampleSize;
+ tMPEGStop = (LONGLONG)ceil(10000000.0 * (double)pOutputPin->dwSamplesProcessed * (double)bytes_written / ((float)pOutputPin->dwSampleSize * pOutputPin->fSamplesPerSec));
+
+ IMediaSample_SetTime(This->pCurrentSample, &tMPEGStart, &tMPEGStop);
+
+ hr = OutputPin_SendSample(&pOutputPin->pin, This->pCurrentSample);
+ if (FAILED(hr))
+ WARN("Error sending sample (%x)\n", hr);
+ }
+ IMediaSample_Release(This->pCurrentSample);
+ }
+ This->pCurrentSample = NULL;
+
+ for (i = 0; i < This->Parser.cStreams; i++)
+ {
+ IPin* ppin;
+ HRESULT hr;
+
+ TRACE("Send End Of Stream to output pin %d\n", i);
+
+ hr = IPin_ConnectedTo(This->Parser.ppPins[i+1], &ppin);
+ if (SUCCEEDED(hr))
+ {
+ hr = IPin_EndOfStream(ppin);
+ IPin_Release(ppin);
+ }
+ if (FAILED(hr))
+ WARN("Error sending EndOfStream to pin %d (%x)\n", i, hr);
+ }
+
+ /* Force the pullpin thread to stop */
+ hr = S_FALSE;
+ }
+
+ return hr;
+}
+
+
+static HRESULT MPEGSplitter_query_accept(LPVOID iface, const AM_MEDIA_TYPE *pmt)
+{
+ if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Stream))
+ return S_FALSE;
+
+ if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_MPEG1Audio))
+ return S_OK;
+
+ if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_MPEG1Video))
+ FIXME("MPEG-1 video streams not yet supported.\n");
+ else if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_MPEG1System))
+ FIXME("MPEG-1 system streams not yet supported.\n");
+ else if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_MPEG1VideoCD))
+ FIXME("MPEG-1 VideoCD streams not yet supported.\n");
+
+ return S_FALSE;
+}
+
+
+static const WCHAR wszAudioStream[] = {'A','u','d','i','o',0};
+static const WCHAR wszVideoStream[] = {'V','i','d','e','o',0};
+
+static HRESULT init_audio_stream(MPEGSplitterImpl *This, PullPin *pPin, uHeader header, PIN_INFO *ppiOutput, AM_MEDIA_TYPE *pamt)
+{
+ static const DWORD freqs[10] = { 44100, 48000, 32000, 22050, 24000,
+ 16000, 11025, 12000, 8000, 0 };
+ static const DWORD tabsel_123[2][3][16] = {
+ { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
+ {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
+ {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
+
+ { {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
+ {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
+ {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
+ };
+
+ WAVEFORMATEX *format;
+ int freq_index;
+ int lsf = 1;
+ int layer;
+
+ ZeroMemory(pamt, sizeof(*pamt));
+ ppiOutput->dir = PINDIR_OUTPUT;
+ ppiOutput->pFilter = (IBaseFilter*)This;
+ wsprintfW(ppiOutput->achName, wszAudioStream);
+
+ memcpy(&pamt->formattype, &FORMAT_WaveFormatEx, sizeof(GUID));
+ memcpy(&pamt->majortype, &MEDIATYPE_Audio, sizeof(GUID));
+ memcpy(&pamt->subtype, &MEDIASUBTYPE_MPEG1AudioPayload, sizeof(GUID));
+
+ pamt->lSampleSize = 0;
+ pamt->bFixedSizeSamples = TRUE;
+ pamt->bTemporalCompression = 0;
+
+
+ if (header.a.mpeg1)
+ lsf = !header.a.no_lsf;
+
+ layer = 4-header.a.inv_layer;
+ freq_index = header.a.freq_idx + (header.a.mpeg1 ? lsf*3 : 6);
+
+ pamt->cbFormat = ((layer==3)? sizeof(MPEGLAYER3WAVEFORMAT) :
+ sizeof(MPEG1WAVEFORMAT));
+ pamt->pbFormat = CoTaskMemAlloc(pamt->cbFormat);
+ if (!pamt->pbFormat)
+ return E_OUTOFMEMORY;
+ ZeroMemory(pamt->pbFormat, pamt->cbFormat);
+ format = (WAVEFORMATEX*)pamt->pbFormat;
+
+ format->wFormatTag = ((layer == 3) ? WAVE_FORMAT_MPEGLAYER3 :
+ WAVE_FORMAT_MPEG);
+ format->nChannels = ((header.a.mode == 3) ? 1 : 2);
+ format->nSamplesPerSec = freqs[freq_index];
+ format->nAvgBytesPerSec = tabsel_123[lsf][layer-1][header.a.br_idx] * 1000 / 8;
+ if (format->nAvgBytesPerSec == 0)
+ {
+ WARN("Variable-bitrate audio is not supported.\n");
+ return E_FAIL;
+ }
+
+ if (layer == 3)
+ format->nBlockAlign = format->nAvgBytesPerSec * 8 * 144 /
+ (format->nSamplesPerSec<<lsf) +
+ (header.a.padding - 4);
+ else if (layer == 2)
+ format->nBlockAlign = format->nAvgBytesPerSec * 8 * 144 /
+ format->nSamplesPerSec + (header.a.padding - 4);
+ else
+ format->nBlockAlign = ((format->nAvgBytesPerSec * 8 * 12 /
+ format->nSamplesPerSec + header.a.padding) << 2) - 4;
+
+ format->wBitsPerSample = 0;
+
+ if (layer == 3)
+ {
+ MPEGLAYER3WAVEFORMAT *mp3format = (MPEGLAYER3WAVEFORMAT*)format;
+
+ format->cbSize = MPEGLAYER3_WFX_EXTRA_BYTES;
+
+ mp3format->wID = MPEGLAYER3_ID_MPEG;
+ mp3format->fdwFlags = (header.a.padding ?
+ MPEGLAYER3_FLAG_PADDING_OFF :
+ MPEGLAYER3_FLAG_PADDING_ON);
+ mp3format->nBlockSize = format->nBlockAlign;
+ mp3format->nFramesPerBlock = 1;
+
+ /* Beware the evil magic numbers. This struct is apparently horribly
+ * under-documented, and the only references I could find had it being
+ * set to this with no real explanation. It works fine though, so I'm
+ * not complaining (yet).
+ */
+ mp3format->nCodecDelay = 1393;
+ }
+ else
+ {
+ MPEG1WAVEFORMAT *mpgformat = (MPEG1WAVEFORMAT*)format;
+
+ format->cbSize = 22;
+
+ mpgformat->fwHeadLayer = ((layer == 1) ? ACM_MPEG_LAYER1 :
+ ((layer == 2) ? ACM_MPEG_LAYER2 :
+ ACM_MPEG_LAYER3));
+ mpgformat->dwHeadBitrate = format->nAvgBytesPerSec * 8;
+ mpgformat->fwHeadMode = ((header.a.mode == 3) ? ACM_MPEG_SINGLECHANNEL :
+ ((header.a.mode == 2) ? ACM_MPEG_DUALCHANNEL :
+ ((header.a.mode == 1) ? ACM_MPEG_JOINTSTEREO :
+ ACM_MPEG_STEREO)));
+ mpgformat->fwHeadModeExt = ((header.a.mode == 1) ? 0x0F : (1<<header.a.mode_ext));
+ mpgformat->wHeadEmphasis = header.a.emphasis + 1;
+ mpgformat->fwHeadFlags = ACM_MPEG_ID_MPEG1;
+ }
+ pamt->subtype.Data1 = format->wFormatTag;
+
+ TRACE("MPEG audio stream detected:\n"
+ "\tLayer %d (%#x)\n"
+ "\tFrequency: %d\n"
+ "\tChannels: %d (%d)\n"
+ "\tBytesPerSec: %d\n",
+ layer, format->wFormatTag, format->nSamplesPerSec,
+ format->nChannels, header.a.mode, format->nAvgBytesPerSec);
+
+ dump_AM_MEDIA_TYPE(pamt);
+
+ return S_OK;
+}
+
+
+static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin)
+{
+ PullPin *pPin = (PullPin *)iface;
+ MPEGSplitterImpl *This = (MPEGSplitterImpl*)pPin->pin.pinInfo.pFilter;
+ ALLOCATOR_PROPERTIES props;
+ HRESULT hr;
+ LONGLONG pos = 0; /* in bytes */
+ uHeader header;
+ int streamtype = 0;
+ LONGLONG total, avail;
+ AM_MEDIA_TYPE amt;
+ PIN_INFO piOutput;
+
+ IAsyncReader_Length(pPin->pReader, &total, &avail);
+ This->EndOfFile = total;
+
+ /* The values are stored big-endian, so flip the value as needed */
+ hr = IAsyncReader_SyncRead(pPin->pReader, pos, 4, (LPVOID)&header);
+ if (SUCCEEDED(hr))
+ {
+ pos += 4;
+ header.value = GET_BE_DWORD(header.value);
+ }
+
+ while(SUCCEEDED(hr) && !(streamtype=head_check(header)))
+ {
+ /* No valid header yet; shift by a byte and check again */
+ header.value <<= 8;
+ hr = IAsyncReader_SyncRead(pPin->pReader, pos++, 1, (LPVOID)GET_MSB_PTR(&header));
+ }
+ if (FAILED(hr))
+ return hr;
+
+ switch(streamtype)
+ {
+ case MPEG_AUDIO_HEADER:
+ hr = init_audio_stream(This, pPin, header, &piOutput, &amt);
+ if (SUCCEEDED(hr))
+ {
+ WAVEFORMATEX *format = (WAVEFORMATEX*)amt.pbFormat;
+
+ props.cbAlign = 1;
+ props.cbPrefix = 0;
+ /* Make the output buffer a multiple of the frame size */
+ props.cbBuffer = 0x4000 / format->nBlockAlign *
+ format->nBlockAlign;
+ props.cBuffers = 1;
+
+ hr = Parser_AddPin(&(This->Parser), &piOutput, &props, &amt,
+ (float)format->nAvgBytesPerSec /
+ (float)format->nBlockAlign,
+ format->nBlockAlign,
+ total);
+ }
+
+ if (FAILED(hr))
+ {
+ if (amt.pbFormat)
+ CoTaskMemFree(amt.pbFormat);
+ ERR("Could not create pin for MPEG audio stream (%x)\n", hr);
+ }
+ break;
+ case MPEG_VIDEO_HEADER:
+ FIXME("MPEG video processing not yet supported!\n");
+ hr = E_FAIL;
+ break;
+ case MPEG_SYSTEM_HEADER:
+ FIXME("MPEG system streams not yet supported!\n");
+ hr = E_FAIL;
+ break;
+
+ default:
+ break;
+ }
+
+ return hr;
+}
+
+static HRESULT MPEGSplitter_cleanup(LPVOID iface)
+{
+ MPEGSplitterImpl *This = (MPEGSplitterImpl*)iface;
+
+ TRACE("(%p)->()\n", This);
+
+ if (This->pCurrentSample)
+ IMediaSample_Release(This->pCurrentSample);
+ This->pCurrentSample = NULL;
+
+ return S_OK;
+}
+
+HRESULT MPEGSplitter_create(IUnknown * pUnkOuter, LPVOID * ppv)
+{
+ MPEGSplitterImpl *This;
+ HRESULT hr = E_FAIL;
+
+ TRACE("(%p, %p)\n", pUnkOuter, ppv);
+
+ *ppv = NULL;
+
+ if (pUnkOuter)
+ return CLASS_E_NOAGGREGATION;
+
+ This = CoTaskMemAlloc(sizeof(MPEGSplitterImpl));
+ if (!This)
+ return E_OUTOFMEMORY;
+
+ ZeroMemory(This, sizeof(MPEGSplitterImpl));
+ hr = Parser_Create(&(This->Parser), &CLSID_MPEG1Splitter, MPEGSplitter_process_sample, MPEGSplitter_query_accept, MPEGSplitter_pre_connect, MPEGSplitter_cleanup);
+ if (FAILED(hr))
+ {
+ CoTaskMemFree(This);
+ return hr;
+ }
+
+ /* Note: This memory is managed by the parser filter once created */
+ *ppv = (LPVOID)This;
+
+ return hr;
+}
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h
index 5b5094d..a483f2a 100644
--- a/dlls/quartz/quartz_private.h
+++ b/dlls/quartz/quartz_private.h
@@ -48,6 +48,7 @@ HRESULT FilterMapper_create(IUnknown *pUnkOuter, LPVOID *ppObj);
HRESULT AsyncReader_create(IUnknown * pUnkOuter, LPVOID * ppv);
HRESULT StdMemAllocator_create(IUnknown * pUnkOuter, LPVOID * ppv);
HRESULT AVISplitter_create(IUnknown * pUnkOuter, LPVOID * ppv);
+HRESULT MPEGSplitter_create(IUnknown * pUnkOuter, LPVOID * ppv);
HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv);
HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv);
HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv);
diff --git a/dlls/quartz/regsvr.c b/dlls/quartz/regsvr.c
index 7206e24..ced43bc 100644
--- a/dlls/quartz/regsvr.c
+++ b/dlls/quartz/regsvr.c
@@ -901,6 +901,12 @@ static struct regsvr_coclass const coclass_list[] = {
"quartz.dll",
"Both"
},
+ { &CLSID_MPEG1Splitter,
+ "MPEG-I Stream Splitter",
+ NULL,
+ "quartz.dll",
+ "Both"
+ },
{ &CLSID_AVIDec,
"AVI Decompressor",
NULL,
@@ -1094,6 +1100,33 @@ static struct regsvr_filter const filter_list[] = {
{ 0xFFFFFFFF },
}
},
+ { &CLSID_MPEG1Splitter,
+ &CLSID_LegacyAmFilterCategory,
+ {'M','P','E','G','-','I',' ','S','t','r','e','a','m',' ','S','p','l','i','t','t','e','r',0},
+ 0x600000,
+ { { 0,
+ { { &MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio },
+ { &MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Video },
+ { &MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System },
+ { &MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1VideoCD },
+ { NULL }
+ },
+ },
+ { REG_PINFLAG_B_OUTPUT,
+ { { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Packet },
+ { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload },
+ { NULL }
+ },
+ },
+ { REG_PINFLAG_B_OUTPUT,
+ { { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Packet },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Payload },
+ { NULL }
+ },
+ },
+ { 0xFFFFFFFF },
+ }
+ },
{ &CLSID_VideoRenderer,
&CLSID_LegacyAmFilterCategory,
{'V','i','d','e','o',' ','R','e','n','d','e','r','e','r',0},
--
1.4.4.4
More information about the wine-patches
mailing list