Mercurial > mplayer.hg
comparison loader/dshow/DS_VideoDec.c @ 1525:9525bff8bea8
fixed BITMAPINFO struct length truncation (WMV8)
author | arpi |
---|---|
date | Wed, 15 Aug 2001 00:38:01 +0000 |
parents | bd6ea9bd3f80 |
children | da26060c81ef |
comparison
equal
deleted
inserted
replaced
1524:1c8f80aeecdb | 1525:9525bff8bea8 |
---|---|
50 static char** m_destptr=0; | 50 static char** m_destptr=0; |
51 | 51 |
52 static DS_Filter* dsf=0; | 52 static DS_Filter* dsf=0; |
53 | 53 |
54 static AM_MEDIA_TYPE m_sOurType, m_sDestType; | 54 static AM_MEDIA_TYPE m_sOurType, m_sDestType; |
55 static VIDEOINFOHEADER m_sVhdr; | 55 static VIDEOINFOHEADER *m_sVhdr; |
56 static VIDEOINFOHEADER *m_sVhdr2; | 56 static VIDEOINFOHEADER *m_sVhdr2; |
57 static void* m_pCust; | 57 static void* m_pCust; |
58 | 58 |
59 static BITMAPINFOHEADER m_bh;//format of input data | 59 static BITMAPINFOHEADER *m_bh;//format of input data |
60 static BitmapInfo m_decoder;//format of decoder output | 60 static BitmapInfo m_decoder;//format of decoder output |
61 static BitmapInfo m_obh; //format of returned frames | 61 static BitmapInfo m_obh; //format of returned frames |
62 // CImage* m_outFrame; | 62 // CImage* m_outFrame; |
63 | 63 |
64 // int m_iState=0; | 64 // int m_iState=0; |
74 //playpos = 0; | 74 //playpos = 0; |
75 //realtime = 0; | 75 //realtime = 0; |
76 | 76 |
77 try | 77 try |
78 { | 78 { |
79 m_bh=*format; | 79 m_bh=format; |
80 memset(&m_obh, 0, sizeof(m_obh)); | 80 memset(&m_obh, 0, sizeof(m_obh)); |
81 m_obh.biSize=sizeof(m_obh); | 81 m_obh.biSize=sizeof(m_obh); |
82 | 82 |
83 #if 0 | |
83 memset(&m_sVhdr, 0, sizeof(m_sVhdr)); | 84 memset(&m_sVhdr, 0, sizeof(m_sVhdr)); |
84 m_sVhdr.bmiHeader=m_bh; | 85 m_sVhdr.bmiHeader=m_bh; |
85 m_sVhdr.rcSource.left=m_sVhdr.rcSource.top=0; | 86 m_sVhdr.rcSource.left=m_sVhdr.rcSource.top=0; |
86 m_sVhdr.rcSource.right=m_sVhdr.bmiHeader.biWidth; | 87 m_sVhdr.rcSource.right=m_sVhdr.bmiHeader.biWidth; |
87 m_sVhdr.rcSource.bottom=m_sVhdr.bmiHeader.biHeight; | 88 m_sVhdr.rcSource.bottom=m_sVhdr.bmiHeader.biHeight; |
88 m_sVhdr.rcTarget=m_sVhdr.rcSource; | 89 m_sVhdr.rcTarget=m_sVhdr.rcSource; |
90 #else | |
91 unsigned bihs = (format->biSize < (int) sizeof(BITMAPINFOHEADER)) ? | |
92 sizeof(BITMAPINFOHEADER) : format->biSize; | |
93 bihs = sizeof(VIDEOINFOHEADER) - sizeof(BITMAPINFOHEADER) + bihs; | |
94 | |
95 m_sVhdr = (VIDEOINFOHEADER*) new char[bihs]; | |
96 memset(m_sVhdr, 0, bihs); | |
97 memcpy(&m_sVhdr->bmiHeader, m_bh, m_bh->biSize); | |
98 | |
99 m_sVhdr->rcSource.left = m_sVhdr->rcSource.top = 0; | |
100 m_sVhdr->rcSource.right = m_sVhdr->bmiHeader.biWidth; | |
101 m_sVhdr->rcSource.bottom = m_sVhdr->bmiHeader.biHeight; | |
102 m_sVhdr->rcTarget = m_sVhdr->rcSource; | |
103 #endif | |
89 m_sOurType.majortype=MEDIATYPE_Video; | 104 m_sOurType.majortype=MEDIATYPE_Video; |
90 | |
91 m_sOurType.subtype=MEDIATYPE_Video; | 105 m_sOurType.subtype=MEDIATYPE_Video; |
92 m_sOurType.subtype.f1=m_sVhdr.bmiHeader.biCompression; | 106 m_sOurType.subtype.f1=m_sVhdr->bmiHeader.biCompression; |
93 m_sOurType.formattype=FORMAT_VideoInfo; | 107 m_sOurType.formattype=FORMAT_VideoInfo; |
94 m_sOurType.bFixedSizeSamples=false; | 108 m_sOurType.bFixedSizeSamples=false; |
95 m_sOurType.bTemporalCompression=true; | 109 m_sOurType.bTemporalCompression=true; |
96 m_sOurType.pUnk=0; | 110 m_sOurType.pUnk=0; |
97 m_sOurType.cbFormat=sizeof(m_sVhdr); | 111 // m_sOurType.cbFormat=sizeof(m_sVhdr); |
98 m_sOurType.pbFormat=(char*)&m_sVhdr; | 112 // m_sOurType.pbFormat=(char*)&m_sVhdr; |
113 m_sOurType.cbFormat = bihs; | |
114 m_sOurType.pbFormat = (char*)m_sVhdr; | |
99 | 115 |
100 m_sVhdr2=(VIDEOINFOHEADER*)(new char[sizeof(VIDEOINFOHEADER)+12]); | 116 m_sVhdr2=(VIDEOINFOHEADER*)(new char[sizeof(VIDEOINFOHEADER)+12]); |
101 *m_sVhdr2=m_sVhdr; | 117 // *m_sVhdr2=m_sVhdr; |
118 memcpy(m_sVhdr2, m_sVhdr, sizeof(VIDEOINFOHEADER)+12); | |
102 m_sVhdr2->bmiHeader.biCompression=0; | 119 m_sVhdr2->bmiHeader.biCompression=0; |
103 m_sVhdr2->bmiHeader.biBitCount=24; | 120 m_sVhdr2->bmiHeader.biBitCount=24; |
104 | 121 |
105 memset(&m_sDestType, 0, sizeof(m_sDestType)); | 122 memset(&m_sDestType, 0, sizeof(m_sDestType)); |
106 m_sDestType.majortype=MEDIATYPE_Video; | 123 m_sDestType.majortype=MEDIATYPE_Video; |
112 ((m_sVhdr2->bmiHeader.biBitCount+7)/8)); | 129 ((m_sVhdr2->bmiHeader.biBitCount+7)/8)); |
113 m_sVhdr2->bmiHeader.biSizeImage=m_sDestType.lSampleSize; | 130 m_sVhdr2->bmiHeader.biSizeImage=m_sDestType.lSampleSize; |
114 m_sDestType.pUnk=0; | 131 m_sDestType.pUnk=0; |
115 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER); | 132 m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER); |
116 m_sDestType.pbFormat=(char*)m_sVhdr2; | 133 m_sDestType.pbFormat=(char*)m_sVhdr2; |
117 | 134 m_obh = *m_bh; |
118 m_obh=m_bh; | |
119 m_obh.setBits(24); | 135 m_obh.setBits(24); |
120 | 136 |
121 HRESULT result; | 137 HRESULT result; |
122 | 138 |
123 dsf=new DS_Filter(); | 139 dsf=new DS_Filter(); |
216 | 232 |
217 extern "C" int DS_VideoDecoder_DecodeFrame(char* src, int size, int is_keyframe, int render){ | 233 extern "C" int DS_VideoDecoder_DecodeFrame(char* src, int size, int is_keyframe, int render){ |
218 | 234 |
219 if(!size)return 0; | 235 if(!size)return 0; |
220 | 236 |
221 m_bh.biSizeImage=size; | 237 m_bh->biSizeImage=size; |
222 | 238 |
223 IMediaSample* sample=0; | 239 IMediaSample* sample=0; |
224 //printf("GetBuffer... (m_pAll=%X) ",dsf->m_pAll);fflush(stdout); | 240 //printf("GetBuffer... (m_pAll=%X) ",dsf->m_pAll);fflush(stdout); |
225 dsf->m_pAll->vt->GetBuffer(dsf->m_pAll, &sample, 0, 0, 0); | 241 dsf->m_pAll->vt->GetBuffer(dsf->m_pAll, &sample, 0, 0, 0); |
226 //printf("OK!\n"); | 242 //printf("OK!\n"); |
334 | 350 |
335 m_decoder=m_obh; | 351 m_decoder=m_obh; |
336 // m_obh=temp; | 352 // m_obh=temp; |
337 // if(csp) | 353 // if(csp) |
338 // m_obh.biBitCount=BitmapInfo::BitCount(csp); | 354 // m_obh.biBitCount=BitmapInfo::BitCount(csp); |
339 m_bh.biBitCount=bits; | 355 m_bh->biBitCount=bits; |
340 if(dsf->m_iState>0) | 356 if(dsf->m_iState>0) |
341 { | 357 { |
342 int old_state=dsf->m_iState; | 358 int old_state=dsf->m_iState; |
343 if(dsf->m_iState==2) DS_VideoDecoder_Stop(); | 359 if(dsf->m_iState==2) DS_VideoDecoder_Stop(); |
344 dsf->m_pInputPin->vt->Disconnect(dsf->m_pInputPin); | 360 dsf->m_pInputPin->vt->Disconnect(dsf->m_pInputPin); |