Index: /dsfilters/dec_mpc/dec_mpc.rc
===================================================================
--- /dsfilters/dec_mpc/dec_mpc.rc	(revision 373)
+++ /dsfilters/dec_mpc/dec_mpc.rc	(revision 374)
@@ -57,4 +57,43 @@
 /////////////////////////////////////////////////////////////////////////////
 //
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,9,0,1
+ PRODUCTVERSION 0,9,0,1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "041b04b0"
+        BEGIN
+            VALUE "Comments", "Musepack SV8 Decoder"
+            VALUE "FileDescription", "mmmpcdec"
+            VALUE "FileVersion", "0, 9, 0, 1"
+            VALUE "InternalName", "mmmpcdec"
+            VALUE "LegalCopyright", "Copyright (C) 2007"
+            VALUE "OriginalFilename", "mmmpcdec.ax"
+            VALUE "ProductName", "MONOGRAM Musepack Decoder"
+            VALUE "ProductVersion", "0, 9, 0, 1"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x41b, 1200
+    END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
 // String Table
 //
@@ -83,26 +122,30 @@
 //
 
-IDD_PAGE_DECODER DIALOGEX 0, 0, 280, 146
+IDD_PAGE_DECODER DIALOGEX 0, 0, 280, 152
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 FONT 8, "MS Shell Dlg", 0, 0, 0x0
 BEGIN
     CONTROL         102,IDC_STATIC,"Static",SS_BITMAP,0,0,280,30
-    GROUPBOX        "Stream attributes",IDC_STATIC,6,36,144,102
+    GROUPBOX        "Stream attributes",IDC_STATIC,6,36,144,108
     LTEXT           "Stream version:",IDC_STATIC,18,54,52,8
     LTEXT           "Sample rate:",IDC_STATIC,18,66,42,8
     LTEXT           "Channels:",IDC_STATIC,18,78,33,8
     LTEXT           "Output format:",IDC_STATIC,18,90,50,8
-    LTEXT           "Frames decoded:",IDC_STATIC,18,102,56,8
+    LTEXT           "Frames decoded:",IDC_STATIC,18,114,56,8
     LTEXT           "SV8",IDC_STATIC_VERSION,78,54,60,8
     LTEXT           "44100 Hz",IDC_STATIC_SAMPLERATE,78,66,60,8
     LTEXT           "Stereo (2)",IDC_STATIC_CHANNELS,78,78,60,8
     LTEXT           "16-bit Integer",IDC_STATIC_OUTPUT,78,90,60,8
-    LTEXT           "0",IDC_STATIC_FRAMES,78,102,60,8
-    CTEXT           "DirectShow filter implemented by Igor Janos",IDC_STATIC,162,66,108,16
-    CTEXT           "http://blog.monogram.sk/janos",IDC_STATIC,162,114,108,8
-    CTEXT           "This software is released under the GNU LGPL licence.",IDC_STATIC,162,42,108,22
-    CTEXT           "http://www.musepack.net",IDC_STATIC,162,126,108,8
-    LTEXT           "Replay gain:",IDC_STATIC,18,114,41,8
-    LTEXT           "0.00 dB",IDC_STATIC_REPLAYGAIN,78,114,60,8
+    LTEXT           "0",IDC_STATIC_FRAMES,78,114,60,8
+    CTEXT           "DirectShow filter implemented by Igor Janos",IDC_STATIC,162,90,108,16
+    CTEXT           "http://blog.monogram.sk/janos",IDC_STATIC,162,120,108,8
+    CTEXT           "This software is released under the GNU LGPL licence.",IDC_STATIC,162,66,108,22
+    CTEXT           "http://www.musepack.net",IDC_STATIC,162,132,108,8
+    LTEXT           "Replay gain:",IDC_STATIC,18,102,41,8
+    LTEXT           "0.00 dB",IDC_STATIC_REPLAYGAIN,78,102,60,8
+    LTEXT           "Avg. Bitrate:",IDC_STATIC,18,126,42,8
+    LTEXT           "0.000 kbps",IDC_STATIC_BITRATE,78,126,60,8
+    CTEXT           "MONOGRAM Musepack Decoder",IDC_STATIC,162,36,108,8
+    CTEXT           "0.9.0.1 alpha",IDC_STATIC,162,48,108,8
 END
 
@@ -121,5 +164,5 @@
         RIGHTMARGIN, 273
         TOPMARGIN, 7
-        BOTTOMMARGIN, 139
+        BOTTOMMARGIN, 145
     END
 END
Index: /dsfilters/dec_mpc/resource.h
===================================================================
--- /dsfilters/dec_mpc/resource.h	(revision 373)
+++ /dsfilters/dec_mpc/resource.h	(revision 374)
@@ -12,4 +12,5 @@
 #define IDC_STATIC_FRAMES               1005
 #define IDC_STATIC_REPLAYGAIN           1006
+#define IDC_STATIC_BITRATE              1007
 
 // Next default values for new objects
@@ -19,5 +20,5 @@
 #define _APS_NEXT_RESOURCE_VALUE        103
 #define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1007
+#define _APS_NEXT_CONTROL_VALUE         1008
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
Index: /dsfilters/dec_mpc/src/mpc_filter.cpp
===================================================================
--- /dsfilters/dec_mpc/src/mpc_filter.cpp	(revision 373)
+++ /dsfilters/dec_mpc/src/mpc_filter.cpp	(revision 374)
@@ -9,30 +9,4 @@
 
 
-
-void MakeNiceSpeed(__int64 bps, CString &v)
-{
-	int r=0;
-	__int64	c=bps;
-	LPCTSTR		rady[] = {
-		_T("bps"),
-		_T("kbps"),
-		_T("mbps"),
-		_T("gbps"),
-		_T("tbps")
-	};
-
-	// spocitame rad
-	while (c > 1000 && r<4) {
-		r++;
-		c = c / 1000;
-	}
-
-	c=bps;
-	for (int i=1; i<r; i++) { c = c/1000; }
-	double d=c / 1000.0;
-
-	v.Format(_T("%5.3f %s"), (float)d, rady[r]);
-}
-
 //-----------------------------------------------------------------------------
 //
@@ -58,4 +32,9 @@
 	m_pInput = new CTransformInputPin(NAME("Input"), this, phr, L"Input");
 	m_pOutput = new CTransformOutputPin(NAME("Output"), this, phr, L"Output");
+
+	bitrate_decay = 0.9;
+	bitrate_cnt = 1;
+	bitrate_blur = 0;
+	frames_decoded = 0;
 }
 
@@ -70,4 +49,7 @@
 	if (riid == IID_ISpecifyPropertyPages) {
 		return GetInterface((ISpecifyPropertyPages*)this, ppv);
+	} else
+	if (riid == IID_IMusepackDecoder) {
+		return GetInterface((IMusepackDecoder*)this, ppv);
 	} else
 		return CBaseFilter::NonDelegatingQueryInterface(riid,ppv);
@@ -242,4 +224,9 @@
 	if (ret < 0) return E_FAIL;
 
+	bitrate_decay = 0.9;
+	bitrate_cnt = 1;
+	bitrate_blur = 0;
+	frames_decoded = 0;
+
 	return hr;
 }
@@ -253,4 +240,9 @@
 	mpc_demux_exit(demux);
 	demux = NULL;
+
+	bitrate_decay = 0.9;
+	bitrate_cnt = 1;
+	bitrate_blur = 0;
+	frames_decoded = 0;
 
 	return hr;
@@ -332,4 +324,6 @@
 	demux->d->decoded_samples = 0;
 
+	int	total_samples_decoded = 0;
+
 	// now scan through the frames
 	int frame_cnt = 1 << stream_info.block_pwr;
@@ -354,4 +348,7 @@
 		}
 
+		// frame counter
+		frames_decoded++;
+
 
 		//---------------------------------------------------------------------
@@ -361,4 +358,5 @@
 		MPC_SAMPLE_FORMAT	*src_samples = frame.buffer;
 		int					decoded_time_samples = frame.samples;
+		total_samples_decoded += frame.samples;
 
 		if (has_timestamp) {
@@ -424,4 +422,10 @@
 	}
 
+	// update bitrate stuff
+	bitrate_blur *= bitrate_decay;
+	bitrate_cnt  *= bitrate_decay;
+	bitrate_blur += (lsize*8);
+	bitrate_cnt  += total_samples_decoded;
+
 	return NOERROR;
 }
@@ -439,4 +443,66 @@
 	return 0;
 }
+
+STDMETHODIMP CMPCDecoder::GetStreamVersion(int *version)
+{
+	if (m_pInput->IsConnected()) {
+		if (version) *version = stream_info.stream_version;
+		return NOERROR;
+	} else {
+		if (version) *version = 0;
+		return E_FAIL;
+	}
+}
+
+STDMETHODIMP CMPCDecoder::GetSamplerate(int *samplerate)
+{
+	if (m_pInput->IsConnected()) {
+		if (samplerate) *samplerate = stream_info.sample_freq;
+		return NOERROR;
+	} else {
+		if (samplerate) *samplerate = 0;
+		return E_FAIL;
+	}
+}
+
+STDMETHODIMP CMPCDecoder::GetChannels(int *channels)
+{
+	if (m_pInput->IsConnected()) {
+		if (channels) *channels = stream_info.channels;
+		return NOERROR;
+	} else {
+		if (channels) *channels = 0;
+		return E_FAIL;
+	}
+}
+
+STDMETHODIMP CMPCDecoder::GetReplaygain(float *gain)
+{
+	if (m_pInput->IsConnected()) {
+		if (gain) *gain = stream_info.gain_title / 256.0;
+		return NOERROR;
+	} else {
+		if (gain) *gain = 0;
+		return E_FAIL;
+	}
+}
+
+STDMETHODIMP CMPCDecoder::GetBitrate(float *bitrate)
+{
+	if (bitrate_cnt > 0 && m_pInput->IsConnected()) {
+
+		if (bitrate) *bitrate = (stream_info.sample_freq * bitrate_blur / bitrate_cnt);
+	} else {
+		if (bitrate) *bitrate = 0;
+	}
+	return NOERROR;
+}
+
+STDMETHODIMP CMPCDecoder::GetFramesDecoded(__int64 *frames)
+{
+	if (frames) *frames = frames_decoded;
+	return NOERROR;
+}
+
 
 
Index: /dsfilters/dec_mpc/src/mpc_filter.h
===================================================================
--- /dsfilters/dec_mpc/src/mpc_filter.h	(revision 373)
+++ /dsfilters/dec_mpc/src/mpc_filter.h	(revision 374)
@@ -49,5 +49,6 @@
 class CMPCDecoder : 
 	public CTransformFilter,
-	public ISpecifyPropertyPages
+	public ISpecifyPropertyPages,
+	public IMusepackDecoder
 {
 public:
@@ -66,4 +67,10 @@
 	mpc_bits_reader		bits;
 	mpc_demux			*demux;
+
+	// let's do some bitrate math
+	double				bitrate_blur;
+	double				bitrate_cnt;
+	double				bitrate_decay;
+	__int64				frames_decoded;
 
 public:
@@ -99,4 +106,13 @@
 	int OpenDemux(mpc_demux **dmx, mpc_streaminfo *si);
 
+	// IMusepackDecoder
+	STDMETHODIMP GetStreamVersion(int *version);
+	STDMETHODIMP GetSamplerate(int *samplerate);
+	STDMETHODIMP GetChannels(int *channels);
+	STDMETHODIMP GetReplaygain(float *gain);
+	STDMETHODIMP GetBitrate(float *bitrate);
+	STDMETHODIMP GetFramesDecoded(__int64 *frames);
+
+
 };
 
Index: /dsfilters/dec_mpc/src/mpc_prop.cpp
===================================================================
--- /dsfilters/dec_mpc/src/mpc_prop.cpp	(revision 373)
+++ /dsfilters/dec_mpc/src/mpc_prop.cpp	(revision 374)
@@ -27,4 +27,29 @@
 }
 
+void MakeNiceSpeed(__int64 bps, CString &v)
+{
+	int r=0;
+	__int64	c=bps;
+	LPCTSTR		rady[] = {
+		_T("bps"),
+		_T("kbps"),
+		_T("mbps"),
+		_T("gbps"),
+		_T("tbps")
+	};
+
+	// spocitame rad
+	while (c > 1000 && r<4) {
+		r++;
+		c = c / 1000;
+	}
+
+	c=bps;
+	for (int i=1; i<r; i++) { c = c/1000; }
+	double d=c / 1000.0;
+
+	v.Format(_T("%5.3f %s"), (float)d, rady[r]);
+}
+
 
 //-----------------------------------------------------------------------------
@@ -40,7 +65,6 @@
 
 CMPCPropertyPage::CMPCPropertyPage(LPUNKNOWN lpUnk, HRESULT *phr) :
-	CBasePropertyPage(NAME("MPC Property Page"), lpUnk, IDD_PAGE_DECODER, IDS_PAGE_DECODER)
-	//,
-	//demux(NULL)
+	CBasePropertyPage(NAME("MPC Property Page"), lpUnk, IDD_PAGE_DECODER, IDS_PAGE_DECODER),
+	decoder(NULL)
 {
 }
@@ -53,7 +77,7 @@
 {
 	// hold a pointer
-	//ASSERT(!demux);
-	//HRESULT hr = pUnknown->QueryInterface(IID_IMusepackSplitter, (void**)&demux);
-	//if (FAILED(hr)) return hr;
+	ASSERT(!decoder);
+	HRESULT hr = pUnknown->QueryInterface(IID_IMusepackDecoder, (void**)&decoder);
+	if (FAILED(hr)) return hr;
 
 	// okej
@@ -63,5 +87,5 @@
 HRESULT CMPCPropertyPage::OnDisconnect()
 {
-	//if (demux) { demux->Release(); demux = NULL; }
+	if (decoder) { decoder->Release(); decoder = NULL; }
 	return NOERROR;
 }
@@ -69,88 +93,72 @@
 HRESULT CMPCPropertyPage::OnActivate()
 {
+	SetTimer(m_Dlg, 0, 1000, NULL);
+	UpdateVisual();
 	return NOERROR;
-	/*
-	demux->SetPropertyPageWindow(m_Dlg);
-
-	// initialize out controls
-	LVCOLUMN	col;
-	col.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
-
-	col.pszText = _T("Name");	col.cx = 150;	col.iSubItem = 0;
-	ListView_InsertColumn(ITEM(IDC_LIST_CONTENT), 0, &col);
-
-	col.pszText = _T("Value");	col.cx = 200;	col.iSubItem = 1;
-	ListView_InsertColumn(ITEM(IDC_LIST_CONTENT), 1, &col);
-
-	UpdateList();
-	return NOERROR;
-	*/
 }
 
 HRESULT CMPCPropertyPage::OnDeactivate()
 {
-	//demux->SetPropertyPageWindow(NULL);
+	KillTimer(m_Dlg, 0);
 	return NOERROR;
 }
 
-/*
-void CMPCPropertyPage::UpdateList()
+void CMPCPropertyPage::UpdateVisual()
 {
-	// first reset everything
-	ListView_DeleteAllItems(ITEM(IDC_LIST_CONTENT));
+	// update visuals
+	CString	tmp;
+	HRESULT hr;
+	int		val;
+	float	fval;
 
-	// now check for the file
-	MPC_File_Info		info;
-	HRESULT hr = demux->GetFileInfo(&info);
-	if (FAILED(hr)) return ;
+	if (!decoder) return ;
 
-	// now fill in the values
-	CString		name, val;
-	LVITEM		i;
-	int			item;
+	// stream version
+	if (SUCCEEDED(decoder->GetStreamVersion(&val))) { tmp.Format(_T("SV%d"), val); } else { tmp = _T("Unknown"); }
+	Static_SetText(ITEM(IDC_STATIC_VERSION), tmp);
 
-	i.mask = LVIF_TEXT;
-	i.iSubItem = 0;
+	// samplerate
+	if (SUCCEEDED(decoder->GetSamplerate(&val))) { tmp.Format(_T("%d Hz"), val); } else { tmp = _T("Unknown"); }
+	Static_SetText(ITEM(IDC_STATIC_SAMPLERATE), tmp);
+	
+	// channels
+	if (SUCCEEDED(decoder->GetChannels(&val))) {
+		switch (val) {
+		case 1:	tmp = _T("Mono (1)"); break;
+		case 2: tmp = _T("Stereo (2)"); break;
+		default: tmp.Format(_T("Other (%d)"), val); break;
+		}
+	} else {
+		tmp = _T("Unknown");
+	}
+	Static_SetText(ITEM(IDC_STATIC_CHANNELS), tmp);
 
-	// Duration
-	i.pszText = _T("Duration");	i.iItem = 0;
-	MakeNiceTime(info.duration * 1000, val);
-	item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
-	ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
+	// so far only one output type
+	Static_SetText(ITEM(IDC_STATIC_OUTPUT), _T("16-bit Integer"));
 
-	// Stream version
-	i.pszText = _T("Stream version");	i.iItem = 1;
-	val.Format(_T("%d"), info.stream_version);
-	item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
-	ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
+	// replay gain
+	if (SUCCEEDED(decoder->GetReplaygain(&fval))) {
+		tmp.Format(_T("%4.2f dB"), fval);
+	} else {
+		tmp = _T("0.00 dB");
+	}
+	Static_SetText(ITEM(IDC_STATIC_REPLAYGAIN), tmp);
 
-	// Stream version
-	i.pszText = _T("Sample rate");	i.iItem = 2;
-	val.Format(_T("%d Hz"), info.sample_rate);
-	item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
-	ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
+	// decoded frames
+	__int64 frames;
+	decoder->GetFramesDecoded(&frames);
+	tmp.Format(_T("%I64d"), frames);
+	Static_SetText(ITEM(IDC_STATIC_FRAMES), tmp);
 
-	// Channels
-	i.pszText = _T("Channels");	i.iItem = 3;
-	val.Format(_T("%d"), info.channels);
-	item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
-	ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
-
-	if (info.stream_version == 8) {
-
-		// Channels
-		i.pszText = _T("Frames per packet");	i.iItem = 4;
-		val.Format(_T("%d"), info.block_frames);
-		item = ListView_InsertItem(ITEM(IDC_LIST_CONTENT), &i);
-		ListView_SetItemText(ITEM(IDC_LIST_CONTENT), item, 1, val.GetBuffer());
-
-	}
+	// bitrate
+	decoder->GetBitrate(&fval);
+	MakeNiceSpeed((__int64)fval, tmp);
+	Static_SetText(ITEM(IDC_STATIC_BITRATE), tmp);
 }
-*/
 
 INT_PTR CMPCPropertyPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
 	switch (uMsg) {
-	case WM_UPDATE_VISUALS:	break; //		UpdateList(); break;
+	case WM_TIMER: UpdateVisual(); break;
 	}
 	return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);
Index: /dsfilters/dec_mpc/src/mpc_prop.h
===================================================================
--- /dsfilters/dec_mpc/src/mpc_prop.h	(revision 373)
+++ /dsfilters/dec_mpc/src/mpc_prop.h	(revision 374)
@@ -20,6 +20,7 @@
 public:
 
-	//IMusepackSplitter		*demux;
-	//void UpdateList();
+	IMusepackDecoder		*decoder;
+
+	void UpdateVisual();
 
 public:
Index: /dsfilters/dec_mpc/src/mpc_types.h
===================================================================
--- /dsfilters/dec_mpc/src/mpc_types.h	(revision 373)
+++ /dsfilters/dec_mpc/src/mpc_types.h	(revision 374)
@@ -16,4 +16,8 @@
 { 0x9024fa6b, 0x7751, 0x4ea7, { 0xb5, 0x75, 0x39, 0x3b, 0x47, 0x24, 0x34, 0xef } };
 
+// {6F57DAB6-C800-4c81-B547-4ED6CC34EDE9}
+static const GUID IID_IMusepackDecoder = 
+{ 0x6f57dab6, 0xc800, 0x4c81, { 0xb5, 0x47, 0x4e, 0xd6, 0xcc, 0x34, 0xed, 0xe9 } };
+
 
 //-----------------------------------------------------------------------------
@@ -28,4 +32,13 @@
 
 
+DECLARE_INTERFACE_(IMusepackDecoder, IUnknown)
+{
+	STDMETHOD(GetStreamVersion)(int *version);
+	STDMETHOD(GetSamplerate)(int *samplerate);
+	STDMETHOD(GetChannels)(int *channels);
+	STDMETHOD(GetReplaygain)(float *gain);
+	STDMETHOD(GetBitrate)(float *bitrate);
+	STDMETHOD(GetFramesDecoded)(__int64 *frames);
+};
 
 
@@ -33,2 +46,3 @@
 
 
+
