annotate loader/dshow/DS_VideoDec.c @ 244:1c3029be6713

Setup_FS fix for directshow
author arpi_esp
date Thu, 29 Mar 2001 12:38:51 +0000
parents fb67a2aa61fe
children 4b91c9120d6a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
1 /********************************************************
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
2
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
3 DirectShow Video decoder implementation
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
4 Copyright 2000 Eugene Kuznetsov (divx@euro.ru)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
5 Converted C++ --> C :) by A'rpi/ESP-team
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
6
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
7 *********************************************************/
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
8
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
9 //#include <config.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
10
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
11 //#include "DS_VideoDecoder.h"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
12 #include <string.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
13 #include <stdlib.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
14 #include <except.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
15 #define __MODULE__ "DirectShow_VideoDecoder"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
16
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
17 #include <errno.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
18 #ifdef HAVE_MALLOC_H
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
19 #include <malloc.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
20 #endif
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
21 //#include <loader.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
22 //#include <wine/winbase.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
23 #include <stdio.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
24 #include <unistd.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
25 #include <fcntl.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
26 #include <strstream>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
27 #include <dlfcn.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
28 #include <sys/types.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
29 #include <sys/mman.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
30
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
31 #include <registry.h>
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
32 #include <wine/winreg.h>
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
33
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
34 #include "guids.h"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
35 #include "interfaces.h"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
36 #include "DS_Filter.h"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
37
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
38 #include "BitmapInfo.h"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
39
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
40 #include <string>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
41 #include <default.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
42
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
43 #include "DS_VideoDec.h"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
44
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
45
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
46 using namespace std;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
47 extern "C" char* def_path;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
48
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
49 static char** m_destptr=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
50
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
51 static DS_Filter* dsf=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
52
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
53 static AM_MEDIA_TYPE m_sOurType, m_sDestType;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
54 static VIDEOINFOHEADER m_sVhdr;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
55 static VIDEOINFOHEADER *m_sVhdr2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
56 static void* m_pCust;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
57
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
58 static BITMAPINFOHEADER m_bh;//format of input data
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
59 static BitmapInfo m_decoder;//format of decoder output
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
60 static BitmapInfo m_obh; //format of returned frames
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
61 // CImage* m_outFrame;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
62
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
63 // int m_iState=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
64
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
65 extern "C" int DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER* format, int flip,char** d_ptr)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
66 // :IVideoDecoder(info), m_sVhdr2(0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
67 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
68
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
69 m_destptr=d_ptr;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
70
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
71 //m_outFrame=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
72 //decpos = 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
73 //playpos = 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
74 //realtime = 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
75
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
76 try
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
77 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
78 m_bh=*format;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
79 memset(&m_obh, 0, sizeof(m_obh));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
80 m_obh.biSize=sizeof(m_obh);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
81
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
82 memset(&m_sVhdr, 0, sizeof m_sVhdr);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
83 m_sVhdr.bmiHeader=m_bh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
84 m_sVhdr.rcSource.left=m_sVhdr.rcSource.top=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
85 m_sVhdr.rcSource.right=m_sVhdr.bmiHeader.biWidth;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
86 m_sVhdr.rcSource.bottom=m_sVhdr.bmiHeader.biHeight;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
87 m_sVhdr.rcTarget=m_sVhdr.rcSource;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
88 m_sOurType.majortype=MEDIATYPE_Video;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
89
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
90 m_sOurType.subtype=MEDIATYPE_Video;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
91 m_sOurType.subtype.f1=m_sVhdr.bmiHeader.biCompression;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
92 m_sOurType.formattype=FORMAT_VideoInfo;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
93 m_sOurType.bFixedSizeSamples=false;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
94 m_sOurType.bTemporalCompression=true;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
95 m_sOurType.pUnk=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
96 m_sOurType.cbFormat=sizeof m_sVhdr;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
97 m_sOurType.pbFormat=(char*)&m_sVhdr;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
98
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
99 m_sVhdr2=(VIDEOINFOHEADER*)(new char[sizeof(VIDEOINFOHEADER)+12]);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
100 *m_sVhdr2=m_sVhdr;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
101 m_sVhdr2->bmiHeader.biCompression=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
102 m_sVhdr2->bmiHeader.biBitCount=24;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
103
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
104 memset(&m_sDestType, 0, sizeof m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
105 m_sDestType.majortype=MEDIATYPE_Video;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
106 m_sDestType.subtype=MEDIASUBTYPE_RGB24;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
107 m_sDestType.formattype=FORMAT_VideoInfo;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
108 m_sDestType.bFixedSizeSamples=true;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
109 m_sDestType.bTemporalCompression=false;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
110 m_sDestType.lSampleSize=abs(m_sVhdr2->bmiHeader.biWidth*m_sVhdr2->bmiHeader.biHeight*
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
111 ((m_sVhdr2->bmiHeader.biBitCount+7)/8));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
112 m_sVhdr2->bmiHeader.biSizeImage=m_sDestType.lSampleSize;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
113 m_sDestType.pUnk=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
114 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
115 m_sDestType.pbFormat=(char*)m_sVhdr2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
116
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
117 m_obh=m_bh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
118 m_obh.setBits(24);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
119
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
120 HRESULT result;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
121
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
122 if(!flip)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
123 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
124 m_sVhdr2->bmiHeader.biHeight*=-1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
125 m_obh.biHeight*=-1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
126 // result=m_pOutputPin->vt->QueryAccept(m_pOutputPin, &m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
127 // if(result)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
128 // throw FATAL("Decoder does not support upside-down frames");
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
129 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
130
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
131 dsf=new DS_Filter();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
132
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
133 dsf->Create(dllname, guid, &m_sOurType, &m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
134
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
135 m_sVhdr2->bmiHeader.biBitCount=16;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
136 m_sVhdr2->bmiHeader.biCompression=fccYUY2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
137 m_sDestType.subtype=MEDIASUBTYPE_YUY2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
138 result=dsf->m_pOutputPin->vt->QueryAccept(dsf->m_pOutputPin, &m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
139 // if(!result) caps=(CAPS)(caps | CAP_YUY2);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
140
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
141 m_sVhdr2->bmiHeader.biBitCount=24;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
142 m_sVhdr2->bmiHeader.biCompression=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
143 m_sDestType.subtype=MEDIASUBTYPE_RGB24;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
144 m_decoder=m_obh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
145 //qual = 0-1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
146 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
147 catch(FatalError& error)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
148 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
149 delete[] m_sVhdr2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
150 return 1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
151 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
152 return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
153 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
154
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
155 extern "C" void DS_VideoDecoder_Start(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
156 if(dsf->m_iState!=1) return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
157 dsf->Start();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
158
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
159 ALLOCATOR_PROPERTIES props, props1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
160 props.cBuffers=1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
161 props.cbBuffer=1024*1024; //m_sDestType.lSampleSize;//don't know how to do this correctly
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
162 props.cbAlign=props.cbPrefix=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
163 dsf->m_pAll->vt->SetProperties(dsf->m_pAll, &props, &props1);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
164 dsf->m_pAll->vt->Commit(dsf->m_pAll);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
165
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
166 // m_outFrame=new CImage(&m_decoder,(unsigned char *)malloc(m_sDestType.lSampleSize),false);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
167 //m_outFrame=new CImage(&m_decoder, 0, false);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
168 // printf("Datap %x\n",m_outFrame->getaddr());
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
170
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
171 // dsf->m_pOurOutput->SetFramePointer((char **)m_outFrame->getaddr()); //!FIXME!
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
172 dsf->m_pOurOutput->SetFramePointer(m_destptr); //!FIXME!
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
173
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
174 // filling = realtime;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
175
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
176 dsf->m_iState=2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
177 return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
178 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
179
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
180 extern "C" void DS_VideoDecoder_Stop(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
181 if(dsf->m_iState!=2) return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
182 dsf->Stop();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
183 dsf->m_pOurOutput->SetFramePointer(0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
184 // free(m_outFrame->data());
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
185 //m_outFrame->release();//just in case
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
186 //m_outFrame=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
187 // FlushCache();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
188 dsf->m_iState=1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
189 return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
190 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
191
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
192 extern "C" void DS_VideoDecoder_Restart(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
193 if(dsf->m_iState!=2) return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
194
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
195 dsf->Stop();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
196 dsf->Start();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
197
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
198 ALLOCATOR_PROPERTIES props, props1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
199 props.cBuffers=1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
200 props.cbBuffer=m_sDestType.lSampleSize;//don't know how to do this correctly
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
201 props.cbAlign=props.cbPrefix=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
202 dsf->m_pAll->vt->SetProperties(dsf->m_pAll, &props, &props1);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
203 dsf->m_pAll->vt->Commit(dsf->m_pAll);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
204 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
205
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
206 extern "C" void DS_VideoDecoder_Close(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
207 if(dsf->m_iState==0) return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
208 if(dsf->m_iState==2) DS_VideoDecoder_Stop();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
209 delete[] m_sVhdr2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
210 // delete m_outFrame;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
211 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
212
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
213 extern "C" int DS_VideoDecoder_DecodeFrame(char* src, int size, int is_keyframe, int render){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
214
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
215 if(!size)return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
216
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
217 m_bh.biSizeImage=size;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
218
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
219 IMediaSample* sample=0;
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
220 //printf("GetBuffer... (m_pAll=%X) ",dsf->m_pAll);fflush(stdout);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
221 dsf->m_pAll->vt->GetBuffer(dsf->m_pAll, &sample, 0, 0, 0);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
222 //printf("OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
223 if(!sample)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
224 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
225 Debug cerr<<"ERROR: null sample"<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
226 return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
227 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
228 char* ptr;
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
229 //printf("GetPtr...");fflush(stdout);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
230 sample->vt->GetPointer(sample, (BYTE **)&ptr);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
231 //printf("OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
232 memcpy(ptr, src, size);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
233 //printf("memcpy OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
234 sample->vt->SetActualDataLength(sample, size);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
235 //printf("SetActualDataLength OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
236 sample->vt->SetSyncPoint(sample, is_keyframe);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
237 //printf("SetSyncPoint OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
238 sample->vt->SetPreroll(sample, !render);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
239 // sample->vt->SetMediaType(sample, &m_sOurType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
240 int result=dsf->m_pImp->vt->Receive(dsf->m_pImp, sample);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
241 if(result)
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
242 printf("Error putting data into input pin %x\n", result);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
243
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
244 sample->vt->Release((IUnknown*)sample);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
245
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
246 return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
247 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
248
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
249 extern "C" int DS_VideoDecoder_SetDestFmt(int bits, int csp){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
250 if(dsf->m_iState==0) return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
251 // if(!CImage::supported(csp, bits)) return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
252 HRESULT result;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
253 // BitmapInfo temp=m_obh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
254 if(csp==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
255 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
256 switch(bits)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
257 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
258 case 15:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
259 m_sDestType.subtype=MEDIASUBTYPE_RGB555;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
260 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
261 case 16:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
262 m_sDestType.subtype=MEDIASUBTYPE_RGB565;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
263 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
264 case 24:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
265 m_sDestType.subtype=MEDIASUBTYPE_RGB24;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
266 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
267 case 32:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
268 m_sDestType.subtype=MEDIASUBTYPE_RGB32;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
269 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
270 default:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
271 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
272 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
273 m_obh.setBits(bits);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
274 // .biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
275 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
276 else
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
277 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
278 m_obh.setSpace(csp);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
279 switch(csp)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
280 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
281 case fccYUY2:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
282 m_sDestType.subtype=MEDIASUBTYPE_YUY2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
283 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
284 case fccYV12:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
285 m_sDestType.subtype=MEDIASUBTYPE_YV12;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
286 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
287 case fccIYUV:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
288 m_sDestType.subtype=MEDIASUBTYPE_IYUV;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
289 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
290 case fccUYVY:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
291 m_sDestType.subtype=MEDIASUBTYPE_UYVY;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
292 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
293 case fccYVYU:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
294 m_sDestType.subtype=MEDIASUBTYPE_YVYU;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
295 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
296 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
297 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
298
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
299 m_sDestType.lSampleSize=m_obh.biSizeImage;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
300 memcpy(&(m_sVhdr2->bmiHeader), &m_obh, sizeof(m_obh));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
301 m_sVhdr2->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
302 if(m_sVhdr2->bmiHeader.biCompression==3)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
303 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER)+12;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
304 else
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
305 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
306
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
307 result=dsf->m_pOutputPin->vt->QueryAccept(dsf->m_pOutputPin, &m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
308
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
309 if(result!=0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
310 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
311 if(csp)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
312 cerr<<"Warning: unsupported color space"<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
313 else
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
314 cerr<<"Warning: unsupported bit depth"<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
315
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
316 m_sDestType.lSampleSize=m_decoder.biSizeImage;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
317 memcpy(&(m_sVhdr2->bmiHeader), &m_decoder, sizeof(m_decoder));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
318 m_sVhdr2->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
319 if(m_sVhdr2->bmiHeader.biCompression==3)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
320 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER)+12;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
321 else
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
322 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
323 return 1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
324 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
325
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
326 m_decoder=m_obh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
327 // m_obh=temp;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
328 // if(csp)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
329 // m_obh.biBitCount=BitmapInfo::BitCount(csp);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
330 m_bh.biBitCount=bits;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
331 if(dsf->m_iState>0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
332 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
333 int old_state=dsf->m_iState;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
334 if(dsf->m_iState==2) DS_VideoDecoder_Stop();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
335 dsf->m_pInputPin->vt->Disconnect(dsf->m_pInputPin);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
336 dsf->m_pOutputPin->vt->Disconnect(dsf->m_pOutputPin);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
337 dsf->m_pOurOutput->SetNewFormat(m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
338 result=dsf->m_pInputPin->vt->ReceiveConnection(dsf->m_pInputPin, dsf->m_pOurInput, &m_sOurType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
339 if(result)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
340 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
341 cerr<<"Error reconnecting input pin "<<hex<<result<<dec<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
342 return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
343 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
344 result=dsf->m_pOutputPin->vt->ReceiveConnection(dsf->m_pOutputPin,
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
345 dsf->m_pOurOutput, &m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
346 if(result)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
347 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
348 cerr<<"Error reconnecting output pin "<<hex<<result<<dec<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
349 return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
350 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
351 if(old_state==2) DS_VideoDecoder_Start();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
352 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
353 return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
354 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
355
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
356
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
357 extern "C" int DS_SetValue_DivX(char* name, int value){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
358 int temp;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
359 if(dsf->m_iState!=2) return VFW_E_NOT_RUNNING;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
360 // brightness 87
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
361 // contrast 74
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
362 // hue 23
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
363 // saturation 20
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
364 // post process mode 0
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
365 // get1 0x01
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
366 // get2 10
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
367 // get3=set2 86
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
368 // get4=set3 73
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
369 // get5=set4 19
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
370 // get6=set5 23
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
371 printf("DivX setting: %s = %d\n",name,value);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
372
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
373 IHidden* hidden=(IHidden*)((int)dsf->m_pFilter+0xb8);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
374 if(strcmp(name, "Brightness")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
375 return hidden->vt->SetSmth2(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
376 if(strcmp(name, "Contrast")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
377 return hidden->vt->SetSmth3(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
378 if(strcmp(name, "Hue")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
379 return hidden->vt->SetSmth5(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
380 if(strcmp(name, "Saturation")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
381 return hidden->vt->SetSmth4(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
382 if(strcmp(name, "Quality")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
383 return hidden->vt->SetSmth(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
384
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
385 printf("Invalid setting!\n");
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
386 return -200;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
387 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
388
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
389 extern "C" int DS_SetAttr_DivX(char* attribute, int value){
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
390 int result, status, newkey, count;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
391 if(strcmp(attribute, "Quality")==0){
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
392 char* keyname="SOFTWARE\\Microsoft\\Scrunch";
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
393 result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
394 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
395 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
396 printf("VideoDecoder::SetExtAttr: registry failure\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
397 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
398 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
399 result=RegSetValueExA(newkey, "Current Post Process Mode", 0, REG_DWORD, &value, 4);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
400 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
401 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
402 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
403 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
404 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
405 value=-1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
406 result=RegSetValueExA(newkey, "Force Post Process Mode", 0, REG_DWORD, &value, 4);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
407 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
408 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
409 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
410 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
411 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
412 RegCloseKey(newkey);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
413 return 0;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
414 }
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
415
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
416 if(
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
417 (strcmp(attribute, "Saturation")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
418 (strcmp(attribute, "Hue")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
419 (strcmp(attribute, "Contrast")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
420 (strcmp(attribute, "Brightness")==0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
421 )
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
422 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
423 char* keyname="SOFTWARE\\Microsoft\\Scrunch\\Video";
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
424 result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
425 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
426 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
427 printf("VideoDecoder::SetExtAttr: registry failure\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
428 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
429 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
430 result=RegSetValueExA(newkey, attribute, 0, REG_DWORD, &value, 4);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
431 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
432 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
433 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
434 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
435 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
436 RegCloseKey(newkey);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
437 return 0;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
438 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
439
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
440 printf("Unknown attribute!\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
441 return -200;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
442 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
443