annotate loader/dshow/DS_VideoDec.c @ 1273:17c13bef14f4

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