summaryrefslogtreecommitdiff
path: root/src/libw32dll/DirectShow/DS_VideoDecoder.c
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-01-06 18:56:19 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-01-06 18:56:19 +0000
commit8377788b342919ec0ff4c29f048b907abce994d4 (patch)
tree4e68ceae3962d2033d0124c232196f6b896cf25f /src/libw32dll/DirectShow/DS_VideoDecoder.c
parent3c6d03ef837577db63f9b7f246978a9ccb009aae (diff)
downloadxine-lib-8377788b342919ec0ff4c29f048b907abce994d4.tar.gz
xine-lib-8377788b342919ec0ff4c29f048b907abce994d4.tar.bz2
updating directshow support with avifile/mplayer changes
CVS patchset: 1357 CVS date: 2002/01/06 18:56:19
Diffstat (limited to 'src/libw32dll/DirectShow/DS_VideoDecoder.c')
-rw-r--r--src/libw32dll/DirectShow/DS_VideoDecoder.c210
1 files changed, 143 insertions, 67 deletions
diff --git a/src/libw32dll/DirectShow/DS_VideoDecoder.c b/src/libw32dll/DirectShow/DS_VideoDecoder.c
index 85f5817a8..faa080fef 100644
--- a/src/libw32dll/DirectShow/DS_VideoDecoder.c
+++ b/src/libw32dll/DirectShow/DS_VideoDecoder.c
@@ -8,7 +8,31 @@
#include "guids.h"
#include "interfaces.h"
+#ifndef NOAVIFILE_HEADERS
+#include "videodecoder.h"
+#else
+#include "libwin32.h"
+#endif
+#include "DS_Filter.h"
+
+struct _DS_VideoDecoder
+{
+ IVideoDecoder iv;
+
+ DS_Filter* m_pDS_Filter;
+ AM_MEDIA_TYPE m_sOurType, m_sDestType;
+ VIDEOINFOHEADER* m_sVhdr;
+ VIDEOINFOHEADER* m_sVhdr2;
+ int m_Caps;//CAPS m_Caps; // capabilities of DirectShow decoder
+ int m_iLastQuality; // remember last quality as integer
+ int m_iMinBuffers;
+ int m_iMaxAuto;
+ int m_bIsDivX; // for speed
+ int m_bIsDivX4; // for speed
+};
+
#include "DS_VideoDecoder.h"
+
#include "../wine/winerror.h"
#ifndef NOAVIFILE_HEADERS
@@ -57,7 +81,7 @@ static ct check[] = {
};
-DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * format, int flip, int maxauto)
+DS_VideoDecoder * DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto)
{
DS_VideoDecoder *this;
HRESULT result;
@@ -70,6 +94,10 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f
this->m_iLastQuality = -1;
this->m_iMaxAuto = maxauto;
+#ifdef LDT_paranoia
+ Setup_LDT_Keeper();
+#endif
+
//memset(&m_obh, 0, sizeof(m_obh));
//m_obh.biSize = sizeof(m_obh);
/*try*/
@@ -140,22 +168,24 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f
* ((this->iv.m_obh.biBitCount + 7) / 8);
- this->m_pDS_Filter = DS_Filter_Create((const char*)info->dll, &info->guid, &this->m_sOurType, &this->m_sDestType);
- if( !this->m_pDS_Filter ) {
- /* FIXME: memory leak */
- return NULL;
- }
+ this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType);
+ if (!this->m_pDS_Filter)
+ {
+ printf("Failed to create DirectShow filter\n");
+ return 0;
+ }
+
if (!flip)
{
- this->m_sVhdr2->bmiHeader.biHeight *= -1;
this->iv.m_obh.biHeight *= -1;
+ this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight;
result = this->m_pDS_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDS_Filter->m_pOutputPin, &this->m_sDestType);
if (result)
{
- printf("Decoder does not support upside-down frames\n");
- this->m_sVhdr2->bmiHeader.biHeight *= -1;
+ printf("Decoder does not support upside-down RGB frames\n");
this->iv.m_obh.biHeight *= -1;
+ this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight;
}
}
@@ -170,7 +200,7 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f
case fccMP42:
case fccWMV2:
//YV12 seems to be broken for DivX :-) codec
- case fccIV50:
+// case fccIV50:
//produces incorrect picture
//m_Caps = (CAPS) (m_Caps & ~CAP_YV12);
//m_Caps = CAP_UYVY;//CAP_YUY2; // | CAP_I420;
@@ -200,11 +230,11 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f
this->m_sDestType.subtype = MEDIASUBTYPE_RGB24;
this->m_iMinBuffers = this->iv.VBUFSIZE;
- this->m_bIsDivX = (strcmp((const char*)info->dll, "divxcvki.ax") == 0
- || strcmp((const char*)info->dll, "divx_c32.ax") == 0
- || strcmp((const char*)info->dll, "wmvds32.ax") == 0
- || strcmp((const char*)info->dll, "wmv8ds32.ax") == 0);
- this->m_bIsDivX4 = (strcmp((const char*)info->dll, "divxdec.ax") == 0);
+ this->m_bIsDivX = (strcmp(dllname, "divxcvki.ax") == 0
+ || strcmp(dllname, "divx_c32.ax") == 0
+ || strcmp(dllname, "wmvds32.ax") == 0
+ || strcmp(dllname, "wmv8ds32.ax") == 0);
+ this->m_bIsDivX4 = (strcmp(dllname, "divxdec.ax") == 0);
if (this->m_bIsDivX)
this->iv.VBUFSIZE += 7;
else if (this->m_bIsDivX4)
@@ -234,7 +264,7 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this)
ALLOCATOR_PROPERTIES props, props1;
Debug printf("DS_VideoDecoder_StartInternal\n");
//cout << "DSSTART" << endl;
- DS_Filter_Start(this->m_pDS_Filter);
+ this->m_pDS_Filter->Start(this->m_pDS_Filter);
props.cBuffers = 1;
props.cbBuffer = this->m_sDestType.lSampleSize;
@@ -244,22 +274,22 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this)
this->m_pDS_Filter->m_pAll->vt->SetProperties(this->m_pDS_Filter->m_pAll, &props, &props1);
this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll);
- //this->iv.m_State = START;
+ this->iv.m_State = START;
}
void DS_VideoDecoder_StopInternal(DS_VideoDecoder *this)
{
- DS_Filter_Stop(this->m_pDS_Filter);
+ this->m_pDS_Filter->Stop(this->m_pDS_Filter);
//??? why was this here ??? m_pOurOutput->SetFramePointer(0);
}
-int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, CImage* pImage)
+int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, char* pImage)
{
IMediaSample* sample = 0;
char* ptr;
int result;
- Debug printf("DS_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,pImage->ptr);
+ Debug printf("DS_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,pImage);
this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0);
@@ -272,18 +302,13 @@ int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int s
//cout << "DECODE " << (void*) pImage << " d: " << (void*) pImage->Data() << endl;
if (pImage)
{
- if (!(pImage->ptr))
- {
- Debug printf("no m_outFrame??\n");
- }
- else
- COutputPin_SetPointer2(this->m_pDS_Filter->m_pOurOutput,(char*)pImage->ptr);
+ this->m_pDS_Filter->m_pOurOutput->SetPointer2(this->m_pDS_Filter->m_pOurOutput,pImage);
}
+ sample->vt->SetActualDataLength(sample, size);
sample->vt->GetPointer(sample, (BYTE **)&ptr);
memcpy(ptr, src, size);
- sample->vt->SetActualDataLength(sample, size);
sample->vt->SetSyncPoint(sample, is_keyframe);
sample->vt->SetPreroll(sample, pImage ? 0 : 1);
// sample->vt->SetMediaType(sample, &m_sOurType);
@@ -294,7 +319,9 @@ int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int s
// crashes inside ...->Receive() fixed now?
//
// nope - but this is surely helpfull - I'll try some more experiments
- //Setup_FS_Segment();
+#ifdef LDT_paranoia
+ Setup_FS_Segment();
+#endif
#if 0
if (!this->m_pDS_Filter || !this->m_pDS_Filter->m_pImp
|| !this->m_pDS_Filter->m_pImp->vt
@@ -381,7 +408,7 @@ int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int s
* bits == 0 - leave unchanged
*/
//int SetDestFmt(DS_VideoDecoder * this, int bits = 24, fourcc_t csp = 0);
-int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
+int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, unsigned int csp)
{
HRESULT result;
int should_test=1;
@@ -394,7 +421,7 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
*/
// BitmapInfo temp = m_obh;
- if (bits != 0)
+ if (!csp) // RGB
{
int ok = true;
@@ -442,10 +469,8 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
}
}
//.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8));
- }
-
- if (csp != 0)
- {
+ } else
+ { // YUV
int ok = true;
switch (csp)
{
@@ -470,19 +495,6 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
}
if (ok) {
- int bits=0;
- switch(csp){
- case fccYUV:
- bits=24;break;
- case fccYUY2:
- case fccUYVY:
- case fccYVYU:
- bits=16;break;
- case fccYV12:
- case fccIYUV:
- case fccI420:
- bits=12;break;
- }
if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0)
this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0
this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER);
@@ -565,7 +577,7 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
this->m_pDS_Filter->m_pInputPin->vt->Disconnect(this->m_pDS_Filter->m_pInputPin);
this->m_pDS_Filter->m_pOutputPin->vt->Disconnect(this->m_pDS_Filter->m_pOutputPin);
- COutputPin_SetNewFormat(this->m_pDS_Filter->m_pOurOutput,&this->m_sDestType);
+ this->m_pDS_Filter->m_pOurOutput->SetNewFormat(this->m_pDS_Filter->m_pOurOutput,&this->m_sDestType);
result = this->m_pDS_Filter->m_pInputPin->vt->ReceiveConnection(this->m_pDS_Filter->m_pInputPin,
this->m_pDS_Filter->m_pOurInput,
&this->m_sOurType);
@@ -600,7 +612,7 @@ int DS_VideoDecoder_SetDirection(DS_VideoDecoder *this, int d)
return 0;
}
-HRESULT DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value)
+int DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* value)
{
/*
if (m_bIsDivX4)
@@ -709,15 +721,14 @@ HRESULT DS_VideoDecoder_GetValue(DS_VideoDecoder *this, const char* name, int* v
return 0;
}
-HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value)
+int DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int value)
{
-/*
- if (m_bIsDivX4)
- {
- IDivxFilterInterface* pIDivx;
- if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_IDivxFilterInterface, (void**)&pIDivx))
+ if (this->m_bIsDivX4) {
+ IDivxFilterInterface* pIDivx=NULL;
+ printf("DS_SetValue for DIVX4, name=%s value=%d\n",name,value);
+ if (this->m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)this->m_pDS_Filter->m_pFilter, &IID_IDivxFilterInterface, (void**)&pIDivx))
{
- Debug printf("No such interface\n");
+ printf("No such interface\n");
return -1;
}
if (strcmp(name, "Postprocessing") == 0)
@@ -729,14 +740,15 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va
else if (strcmp(name, "Saturation") == 0)
pIDivx->vt->put_Saturation(pIDivx, value);
else if (strcmp(name, "MaxAuto") == 0)
- m_iMaxAuto = value;
+ this->m_iMaxAuto = value;
pIDivx->vt->Release((IUnknown*)pIDivx);
//printf("Set %s %d\n", name, value);
return 0;
}
- else if (m_bIsDivX)
- {
- if (m_State != START)
+
+ if (this->m_bIsDivX) {
+ IHidden* hidden;
+ if (this->iv.m_State != START)
return VFW_E_NOT_RUNNING;
//cout << "set value " << name << " " << value << endl;
@@ -751,10 +763,11 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va
// get4=set3 73
// get5=set4 19
// get6=set5 23
- IHidden* hidden = (IHidden*)((int)m_pDS_Filter->m_pFilter + 0xb8);
+ hidden = (IHidden*)((int)this->m_pDS_Filter->m_pFilter + 0xb8);
+ printf("DS_SetValue for DIVX, name=%s value=%d\n",name,value);
if (strcmp(name, "Quality") == 0)
{
- m_iLastQuality = value;
+ this->m_iLastQuality = value;
return hidden->vt->SetSmth(hidden, value, 0);
}
if (strcmp(name, "Brightness") == 0)
@@ -767,11 +780,12 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va
return hidden->vt->SetSmth5(hidden, value, 0);
if (strcmp(name, "MaxAuto") == 0)
{
- m_iMaxAuto = value;
- return 0;
+ this->m_iMaxAuto = value;
}
+ return 0;
}
- else if (strcmp((const char*)record.dll, "ir50_32.dll") == 0)
+#if 0
+ if (strcmp((const char*)record.dll, "ir50_32.dll") == 0)
{
IHidden2* hidden = 0;
if (m_pDS_Filter->m_pFilter->vt->QueryInterface((IUnknown*)m_pDS_Filter->m_pFilter, &IID_Iv50Hidden, (void**)&hidden))
@@ -811,9 +825,71 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va
return result;
}
-*/
+#endif
+ printf("DS_SetValue for ????, name=%s value=%d\n",name,value);
return 0;
}
/*
-vim: tabstop=8
+vim: vi* sux.
+hahaha
*/
+
+#if 0
+int DS_SetAttr_DivX(char* attribute, int value){
+ int result, status, newkey, count;
+ if(strcmp(attribute, "Quality")==0){
+ char* keyname="SOFTWARE\\Microsoft\\Scrunch";
+ result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
+ if(result!=0)
+ {
+ printf("VideoDecoder::SetExtAttr: registry failure\n");
+ return -1;
+ }
+ result=RegSetValueExA(newkey, "Current Post Process Mode", 0, REG_DWORD, &value, 4);
+ if(result!=0)
+ {
+ printf("VideoDecoder::SetExtAttr: error writing value\n");
+ return -1;
+ }
+ value=-1;
+ result=RegSetValueExA(newkey, "Force Post Process Mode", 0, REG_DWORD, &value, 4);
+ if(result!=0)
+ {
+ printf("VideoDecoder::SetExtAttr: error writing value\n");
+ return -1;
+ }
+ RegCloseKey(newkey);
+ return 0;
+ }
+
+ if(
+ (strcmp(attribute, "Saturation")==0) ||
+ (strcmp(attribute, "Hue")==0) ||
+ (strcmp(attribute, "Contrast")==0) ||
+ (strcmp(attribute, "Brightness")==0)
+ )
+ {
+ char* keyname="SOFTWARE\\Microsoft\\Scrunch\\Video";
+ result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
+ if(result!=0)
+ {
+ printf("VideoDecoder::SetExtAttr: registry failure\n");
+ return -1;
+ }
+ result=RegSetValueExA(newkey, attribute, 0, REG_DWORD, &value, 4);
+ if(result!=0)
+ {
+ printf("VideoDecoder::SetExtAttr: error writing value\n");
+ return -1;
+ }
+ RegCloseKey(newkey);
+ return 0;
+ }
+
+ printf("Unknown attribute!\n");
+ return -200;
+}
+#endif
+
+
+