annotate loader/dshow/DS_VideoDec.c @ 819:291de1f95724

Fixed cpu model detection with non-bash bourne shell
author eyck
date Thu, 17 May 2001 09:36:36 +0000
parents 9355b2ae634e
children 269780d31b51
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
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
82 memset(&m_sVhdr, 0, sizeof(m_sVhdr));
169
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;
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
96 m_sOurType.cbFormat=sizeof(m_sVhdr);
169
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
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
104 memset(&m_sDestType, 0, sizeof(m_sDestType));
169
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
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
122 dsf=new DS_Filter();
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
123 dsf->Create(dllname, guid, &m_sOurType, &m_sDestType);
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
124
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
125 if(!flip)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
126 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
127 m_sVhdr2->bmiHeader.biHeight*=-1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
128 m_obh.biHeight*=-1;
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
129 result=dsf->m_pOutputPin->vt->QueryAccept(dsf->m_pOutputPin, &m_sDestType);
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
130 if(result){
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
131 printf("DShow: Decoder does not support upside-down frames");
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
132 m_obh.biHeight*=-1;
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
133 }
169
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
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
136 #if 0
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
137 m_sVhdr2->bmiHeader.biBitCount=16;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
138 m_sVhdr2->bmiHeader.biCompression=fccYUY2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
139 m_sDestType.subtype=MEDIASUBTYPE_YUY2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
140 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
141 // if(!result) caps=(CAPS)(caps | CAP_YUY2);
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
142 #endif
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
143
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
144 m_sVhdr2->bmiHeader.biBitCount=24;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
145 m_sVhdr2->bmiHeader.biCompression=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
146 m_sDestType.subtype=MEDIASUBTYPE_RGB24;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
147 m_decoder=m_obh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
148 //qual = 0-1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
149 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
150 catch(FatalError& error)
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 delete[] m_sVhdr2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
153 return 1;
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 return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
156 }
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 extern "C" void DS_VideoDecoder_Start(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
159 if(dsf->m_iState!=1) return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
160 dsf->Start();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
161
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
162 ALLOCATOR_PROPERTIES props, props1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
163 props.cBuffers=1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
164 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
165 props.cbAlign=props.cbPrefix=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
166 dsf->m_pAll->vt->SetProperties(dsf->m_pAll, &props, &props1);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
167 dsf->m_pAll->vt->Commit(dsf->m_pAll);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
168
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
169 // 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
170 //m_outFrame=new CImage(&m_decoder, 0, false);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
171 // printf("Datap %x\n",m_outFrame->getaddr());
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
172
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 // dsf->m_pOurOutput->SetFramePointer((char **)m_outFrame->getaddr()); //!FIXME!
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
175 dsf->m_pOurOutput->SetFramePointer(m_destptr); //!FIXME!
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
176
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
177 // filling = realtime;
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 dsf->m_iState=2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
180 return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
181 }
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 extern "C" void DS_VideoDecoder_Stop(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
184 if(dsf->m_iState!=2) return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
185 dsf->Stop();
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 468
diff changeset
186 // dsf->m_pOurOutput->SetFramePointer(0);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
187 // free(m_outFrame->data());
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
188 //m_outFrame->release();//just in case
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
189 //m_outFrame=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
190 // FlushCache();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
191 dsf->m_iState=1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
192 return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
193 }
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 extern "C" void DS_VideoDecoder_Restart(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
196 if(dsf->m_iState!=2) return;
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 dsf->Stop();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
199 dsf->Start();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
200
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
201 ALLOCATOR_PROPERTIES props, props1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
202 props.cBuffers=1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
203 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
204 props.cbAlign=props.cbPrefix=0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
205 dsf->m_pAll->vt->SetProperties(dsf->m_pAll, &props, &props1);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
206 dsf->m_pAll->vt->Commit(dsf->m_pAll);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
207 }
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 extern "C" void DS_VideoDecoder_Close(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
210 if(dsf->m_iState==0) return;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
211 if(dsf->m_iState==2) DS_VideoDecoder_Stop();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
212 delete[] m_sVhdr2;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
213 // delete m_outFrame;
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
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
216 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
217
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
218 if(!size)return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
219
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
220 m_bh.biSizeImage=size;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
221
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
222 IMediaSample* sample=0;
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
223 //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
224 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
225 //printf("OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
226 if(!sample)
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 Debug cerr<<"ERROR: null sample"<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
229 return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
230 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
231 char* ptr;
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
232 //printf("GetPtr...");fflush(stdout);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
233 sample->vt->GetPointer(sample, (BYTE **)&ptr);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
234 //printf("OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
235 memcpy(ptr, src, size);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
236 //printf("memcpy OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
237 sample->vt->SetActualDataLength(sample, size);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
238 //printf("SetActualDataLength OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
239 sample->vt->SetSyncPoint(sample, is_keyframe);
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
240 //printf("SetSyncPoint OK!\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
241 sample->vt->SetPreroll(sample, !render);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
242 // sample->vt->SetMediaType(sample, &m_sOurType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
243 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
244 if(result)
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
245 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
246
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
247 sample->vt->Release((IUnknown*)sample);
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 return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
250 }
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 extern "C" int DS_VideoDecoder_SetDestFmt(int bits, int csp){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
253 if(dsf->m_iState==0) return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
254 // if(!CImage::supported(csp, bits)) return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
255 HRESULT result;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
256 // BitmapInfo temp=m_obh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
257 if(csp==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
258 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
259 switch(bits)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
260 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
261 case 15:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
262 m_sDestType.subtype=MEDIASUBTYPE_RGB555;
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 16:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
265 m_sDestType.subtype=MEDIASUBTYPE_RGB565;
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 24:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
268 m_sDestType.subtype=MEDIASUBTYPE_RGB24;
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 case 32:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
271 m_sDestType.subtype=MEDIASUBTYPE_RGB32;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
272 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
273 default:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
274 break;
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 m_obh.setBits(bits);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
277 // .biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
278 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
279 else
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
280 {
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
281 m_obh.setSpace(csp,bits);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
282 switch(csp)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
283 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
284 case fccYUY2:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
285 m_sDestType.subtype=MEDIASUBTYPE_YUY2;
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
286 printf("DShow: using YUY2 colorspace\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
287 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
288 case fccYV12:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
289 m_sDestType.subtype=MEDIASUBTYPE_YV12;
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
290 printf("DShow: using YV12 colorspace\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
291 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
292 case fccIYUV:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
293 m_sDestType.subtype=MEDIASUBTYPE_IYUV;
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
294 printf("DShow: using IYUV colorspace\n");
169
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 case fccUYVY:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
297 m_sDestType.subtype=MEDIASUBTYPE_UYVY;
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
298 printf("DShow: using UYVY colorspace\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
299 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
300 case fccYVYU:
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
301 m_sDestType.subtype=MEDIASUBTYPE_YVYU;
468
4b91c9120d6a other YUV formats support
arpi_esp
parents: 173
diff changeset
302 printf("DShow: using YVYU colorspace\n");
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
303 break;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
304 }
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 m_sDestType.lSampleSize=m_obh.biSizeImage;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
308 memcpy(&(m_sVhdr2->bmiHeader), &m_obh, sizeof(m_obh));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
309 m_sVhdr2->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
310 if(m_sVhdr2->bmiHeader.biCompression==3)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
311 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER)+12;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
312 else
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
313 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
314
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
315 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
316
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
317 if(result!=0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
318 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
319 if(csp)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
320 cerr<<"Warning: unsupported color space"<<endl;
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 cerr<<"Warning: unsupported bit depth"<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
323
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
324 m_sDestType.lSampleSize=m_decoder.biSizeImage;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
325 memcpy(&(m_sVhdr2->bmiHeader), &m_decoder, sizeof(m_decoder));
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
326 m_sVhdr2->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
327 if(m_sVhdr2->bmiHeader.biCompression==3)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
328 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER)+12;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
329 else
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
330 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
331 return 1;
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
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
334 m_decoder=m_obh;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
335 // m_obh=temp;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
336 // if(csp)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
337 // m_obh.biBitCount=BitmapInfo::BitCount(csp);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
338 m_bh.biBitCount=bits;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
339 if(dsf->m_iState>0)
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 int old_state=dsf->m_iState;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
342 if(dsf->m_iState==2) DS_VideoDecoder_Stop();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
343 dsf->m_pInputPin->vt->Disconnect(dsf->m_pInputPin);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
344 dsf->m_pOutputPin->vt->Disconnect(dsf->m_pOutputPin);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
345 dsf->m_pOurOutput->SetNewFormat(m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
346 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
347 if(result)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
348 {
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
349 cerr<<"Error reconnecting input pin "<<hex<<result<<dec<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
350 return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
351 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
352 result=dsf->m_pOutputPin->vt->ReceiveConnection(dsf->m_pOutputPin,
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
353 dsf->m_pOurOutput, &m_sDestType);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
354 if(result)
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 cerr<<"Error reconnecting output pin "<<hex<<result<<dec<<endl;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
357 return -1;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
358 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
359 if(old_state==2) DS_VideoDecoder_Start();
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
360 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
361 return 0;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
362 }
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 extern "C" int DS_SetValue_DivX(char* name, int value){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
366 int temp;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
367 if(dsf->m_iState!=2) return VFW_E_NOT_RUNNING;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
368 // brightness 87
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
369 // contrast 74
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
370 // hue 23
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
371 // saturation 20
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
372 // post process mode 0
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
373 // get1 0x01
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
374 // get2 10
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
375 // get3=set2 86
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
376 // get4=set3 73
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
377 // get5=set4 19
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
378 // get6=set5 23
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
379 printf("DivX setting: %s = %d\n",name,value);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
380
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
381 IHidden* hidden=(IHidden*)((int)dsf->m_pFilter+0xb8);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
382 if(strcmp(name, "Brightness")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
383 return hidden->vt->SetSmth2(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
384 if(strcmp(name, "Contrast")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
385 return hidden->vt->SetSmth3(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
386 if(strcmp(name, "Hue")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
387 return hidden->vt->SetSmth5(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
388 if(strcmp(name, "Saturation")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
389 return hidden->vt->SetSmth4(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
390 if(strcmp(name, "Quality")==0)
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
391 return hidden->vt->SetSmth(hidden, value, 0);
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
392
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
393 printf("Invalid setting!\n");
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
394 return -200;
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
395 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
396
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
397 extern "C" int DS_SetAttr_DivX(char* attribute, int value){
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
398 int result, status, newkey, count;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
399 if(strcmp(attribute, "Quality")==0){
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
400 char* keyname="SOFTWARE\\Microsoft\\Scrunch";
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
401 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
402 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
403 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
404 printf("VideoDecoder::SetExtAttr: registry failure\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
405 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
406 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
407 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
408 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
409 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
410 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
411 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
412 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
413 value=-1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
414 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
415 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
416 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
417 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
418 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
419 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
420 RegCloseKey(newkey);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
421 return 0;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
422 }
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
423
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
424 if(
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
425 (strcmp(attribute, "Saturation")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
426 (strcmp(attribute, "Hue")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
427 (strcmp(attribute, "Contrast")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
428 (strcmp(attribute, "Brightness")==0)
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 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
431 char* keyname="SOFTWARE\\Microsoft\\Scrunch\\Video";
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
432 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
433 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
434 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
435 printf("VideoDecoder::SetExtAttr: registry failure\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
436 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
437 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
438 result=RegSetValueExA(newkey, attribute, 0, REG_DWORD, &value, 4);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
439 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
440 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
441 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
442 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
443 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
444 RegCloseKey(newkey);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
445 return 0;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
446 }
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 printf("Unknown attribute!\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
449 return -200;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
450 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
451