00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "stdafx.h"
00023 #include <initguid.h>
00024 #include "..\..\include\moreuuids.h"
00025 #include "MediaTypes.h"
00026 #include "DSUtil.h"
00027
00028 #define VIH_NORMAL (sizeof(VIDEOINFOHEADER))
00029 #define VIH_BITFIELDS (sizeof(VIDEOINFOHEADER)+3*sizeof(RGBQUAD))
00030 #define VIH2_NORMAL (sizeof(VIDEOINFOHEADER2))
00031 #define VIH2_BITFIELDS (sizeof(VIDEOINFOHEADER2)+3*sizeof(RGBQUAD))
00032 #define BIH_SIZE (sizeof(BITMAPINFOHEADER))
00033
00034 VIH vihs[] =
00035 {
00036
00037 {
00038 {
00039 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00040 {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0}
00041 },
00042 {0, 0, 0},
00043 VIH_NORMAL,
00044 &MEDIASUBTYPE_YUY2
00045 },
00046
00047 {
00048 {
00049 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00050 {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0}
00051 },
00052 {0, 0, 0},
00053 VIH_NORMAL,
00054 &MEDIASUBTYPE_YV12
00055 },
00056
00057 {
00058 {
00059 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00060 {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0}
00061 },
00062 {0, 0, 0},
00063 VIH_NORMAL,
00064 &MEDIASUBTYPE_I420
00065 },
00066
00067 {
00068 {
00069 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00070 {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0}
00071 },
00072 {0, 0, 0},
00073 VIH_NORMAL,
00074 &MEDIASUBTYPE_IYUV
00075 },
00076
00077 {
00078 {
00079 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00080 {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0}
00081 },
00082 {0, 0, 0},
00083 VIH_NORMAL,
00084 &MEDIASUBTYPE_RGB32
00085 },
00086
00087 {
00088 {
00089 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00090 {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0}
00091 },
00092 {0xFF0000, 0x00FF00, 0x0000FF},
00093 VIH_BITFIELDS,
00094 &MEDIASUBTYPE_RGB32
00095 },
00096
00097 {
00098 {
00099 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00100 {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0}
00101 },
00102 {0, 0, 0},
00103 VIH_NORMAL,
00104 &MEDIASUBTYPE_ARGB32
00105 },
00106
00107 {
00108 {
00109 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00110 {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0}
00111 },
00112 {0xFF0000, 0x00FF00, 0x0000FF},
00113 VIH_BITFIELDS,
00114 &MEDIASUBTYPE_ARGB32
00115 },
00116
00117 {
00118 {
00119 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00120 {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0}
00121 },
00122 {0, 0, 0},
00123 VIH_NORMAL,
00124 &MEDIASUBTYPE_RGB24
00125 },
00126
00127 {
00128 {
00129 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00130 {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0}
00131 },
00132 {0xFF0000, 0x00FF00, 0x0000FF},
00133 VIH_BITFIELDS,
00134 &MEDIASUBTYPE_RGB24
00135 },
00136
00137 {
00138 {
00139 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00140 {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0}
00141 },
00142 {0, 0, 0},
00143 VIH_NORMAL,
00144 &MEDIASUBTYPE_RGB565
00145 },
00146
00147 {
00148 {
00149 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00150 {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0}
00151 },
00152 {0xF800, 0x07E0, 0x001F},
00153 VIH_BITFIELDS,
00154 &MEDIASUBTYPE_RGB565
00155 },
00156
00157 {
00158 {
00159 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00160 {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0}
00161 },
00162 {0, 0, 0},
00163 VIH_NORMAL,
00164 &MEDIASUBTYPE_RGB555
00165 },
00166
00167 {
00168 {
00169 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
00170 {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0}
00171 },
00172 {0x7C00, 0x03E0, 0x001F},
00173 VIH_BITFIELDS,
00174 &MEDIASUBTYPE_RGB555
00175 },
00176 };
00177
00178 VIH2 vih2s[] =
00179 {
00180
00181 {
00182 {
00183 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00184 {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0}
00185 },
00186 {0, 0, 0},
00187 VIH2_NORMAL,
00188 &MEDIASUBTYPE_YUY2
00189 },
00190
00191 {
00192 {
00193 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00194 {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0}
00195 },
00196 {0, 0, 0},
00197 VIH2_NORMAL,
00198 &MEDIASUBTYPE_YV12
00199 },
00200
00201 {
00202 {
00203 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00204 {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0}
00205 },
00206 {0, 0, 0},
00207 VIH2_NORMAL,
00208 &MEDIASUBTYPE_I420
00209 },
00210
00211 {
00212 {
00213 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00214 {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0}
00215 },
00216 {0, 0, 0},
00217 VIH2_NORMAL,
00218 &MEDIASUBTYPE_IYUV
00219 },
00220
00221 {
00222 {
00223 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00224 {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0}
00225 },
00226 {0, 0, 0},
00227 VIH2_NORMAL,
00228 &MEDIASUBTYPE_RGB32
00229 },
00230
00231 {
00232 {
00233 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00234 {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0}
00235 },
00236 {0xFF0000, 0x00FF00, 0x0000FF},
00237 VIH2_BITFIELDS,
00238 &MEDIASUBTYPE_RGB32
00239 },
00240
00241 {
00242 {
00243 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00244 {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0}
00245 },
00246 {0, 0, 0},
00247 VIH2_NORMAL,
00248 &MEDIASUBTYPE_ARGB32
00249 },
00250
00251 {
00252 {
00253 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00254 {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0}
00255 },
00256 {0xFF0000, 0x00FF00, 0x0000FF},
00257 VIH2_BITFIELDS,
00258 &MEDIASUBTYPE_ARGB32
00259 },
00260
00261 {
00262 {
00263 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00264 {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0}
00265 },
00266 {0, 0, 0},
00267 VIH2_NORMAL,
00268 &MEDIASUBTYPE_RGB24
00269 },
00270
00271 {
00272 {
00273 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00274 {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0}
00275 },
00276 {0xFF0000, 0x00FF00, 0x0000FF},
00277 VIH2_BITFIELDS,
00278 &MEDIASUBTYPE_RGB24
00279 },
00280
00281 {
00282 {
00283 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00284 {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0}
00285 },
00286 {0, 0, 0},
00287 VIH2_NORMAL,
00288 &MEDIASUBTYPE_RGB565
00289 },
00290
00291 {
00292 {
00293 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00294 {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0}
00295 },
00296 {0xF800, 0x07E0, 0x001F},
00297 VIH2_BITFIELDS,
00298 &MEDIASUBTYPE_RGB565
00299 },
00300
00301 {
00302 {
00303 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00304 {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0}
00305 },
00306 {0, 0, 0},
00307 VIH2_NORMAL,
00308 &MEDIASUBTYPE_RGB555
00309 },
00310
00311 {
00312 {
00313 {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00314 {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0}
00315 },
00316 {0x7C00, 0x03E0, 0x001F},
00317 VIH2_BITFIELDS,
00318 &MEDIASUBTYPE_RGB555
00319 },
00320 };
00321
00322 int VIHSIZE = countof(vihs);
00323
00324 CString VIH2String(int i)
00325 {
00326 CString ret = CString(GuidNames[*vihs[i].subtype]);
00327 if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) ret = ret.Mid(13);
00328 if(vihs[i].vih.bmiHeader.biCompression == 3) ret += _T(" BITF");
00329 if(*vihs[i].subtype == MEDIASUBTYPE_I420) ret = _T("I420");
00330 return(ret);
00331 }
00332
00333 CString Subtype2String(const GUID& subtype)
00334 {
00335 CString ret = CString(GuidNames[subtype]);
00336 if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) ret = ret.Mid(13);
00337 if(subtype == MEDIASUBTYPE_I420) ret = _T("I420");
00338 return(ret);
00339 }
00340
00341 void CorrectMediaType(AM_MEDIA_TYPE* pmt)
00342 {
00343 if(!pmt) return;
00344
00345 CMediaType mt(*pmt);
00346
00347 if(mt.formattype == FORMAT_VideoInfo)
00348 {
00349 VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
00350
00351 for(int i = 0; i < VIHSIZE; i++)
00352 {
00353 if(mt.subtype == *vihs[i].subtype
00354 && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression)
00355 {
00356 mt.AllocFormatBuffer(vihs[i].size);
00357 memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
00358 memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER));
00359 break;
00360 }
00361 }
00362 }
00363 else if(mt.formattype == FORMAT_VideoInfo2)
00364 {
00365 VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
00366
00367 for(int i = 0; i < VIHSIZE; i++)
00368 {
00369 if(mt.subtype == *vih2s[i].subtype
00370 && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression)
00371 {
00372 mt.AllocFormatBuffer(vih2s[i].size);
00373 memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
00374 memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER2));
00375 break;
00376 }
00377 }
00378 }
00379
00380 CopyMediaType(pmt, &mt);
00381 }