Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/DSUtil')
-rw-r--r--src/DSUtil/AudioParser.cpp522
-rw-r--r--src/DSUtil/AudioParser.h12
-rw-r--r--src/DSUtil/DSMPropertyBag.cpp446
-rw-r--r--src/DSUtil/DSMPropertyBag.h228
-rw-r--r--src/DSUtil/DSUtil.cpp4760
-rw-r--r--src/DSUtil/DSUtil.h74
-rw-r--r--src/DSUtil/FontInstaller.cpp130
-rw-r--r--src/DSUtil/FontInstaller.h28
-rw-r--r--src/DSUtil/GolombBuffer.cpp84
-rw-r--r--src/DSUtil/GolombBuffer.h46
-rw-r--r--src/DSUtil/H264Nalu.cpp108
-rw-r--r--src/DSUtil/H264Nalu.h76
-rw-r--r--src/DSUtil/HdmvClipInfo.cpp747
-rw-r--r--src/DSUtil/HdmvClipInfo.h204
-rw-r--r--src/DSUtil/MediaTypeEx.cpp1323
-rw-r--r--src/DSUtil/MediaTypeEx.h18
-rw-r--r--src/DSUtil/MediaTypes.cpp654
-rw-r--r--src/DSUtil/MediaTypes.h16
-rw-r--r--src/DSUtil/Mpeg2Def.h250
-rw-r--r--src/DSUtil/NullRenderers.cpp546
-rw-r--r--src/DSUtil/NullRenderers.h54
-rw-r--r--src/DSUtil/SysVersion.cpp8
-rw-r--r--src/DSUtil/SysVersion.h24
-rw-r--r--src/DSUtil/WinAPIUtils.cpp376
-rw-r--r--src/DSUtil/WinAPIUtils.h4
-rw-r--r--src/DSUtil/text.cpp260
-rw-r--r--src/DSUtil/text.h64
27 files changed, 5529 insertions, 5533 deletions
diff --git a/src/DSUtil/AudioParser.cpp b/src/DSUtil/AudioParser.cpp
index 8d7a0e7e4..f8246db81 100644
--- a/src/DSUtil/AudioParser.cpp
+++ b/src/DSUtil/AudioParser.cpp
@@ -39,293 +39,303 @@
#define AC3_CHANNEL_MASK 15
#define AC3_LFE 16
-int GetAC3FrameSize(const BYTE *buf)
+int GetAC3FrameSize(const BYTE* buf)
{
- if (*(WORD*)buf != AC3_SYNC_WORD) // syncword
- return 0;
-
- int frame_size;
-
- if (buf[5] >> 3 <= 10) { // Normal AC-3
- static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
-
- int frmsizecod = buf[4] & 0x3F;
- if (frmsizecod >= 38)
- return 0;
-
- int rate = rates[frmsizecod >> 1];
- switch (buf[4] & 0xc0) {
- case 0:
- frame_size = 4 * rate;
- break;
- case 0x40:
- frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
- break;
- case 0x80:
- frame_size = 6 * rate;
- break;
- default:
- return 0;
- }
- } else { /// Enhanced AC-3
- frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
- }
- return frame_size;
+ if (*(WORD*)buf != AC3_SYNC_WORD) { // syncword
+ return 0;
+ }
+
+ int frame_size;
+
+ if (buf[5] >> 3 <= 10) { // Normal AC-3
+ static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
+
+ int frmsizecod = buf[4] & 0x3F;
+ if (frmsizecod >= 38) {
+ return 0;
+ }
+
+ int rate = rates[frmsizecod >> 1];
+ switch (buf[4] & 0xc0) {
+ case 0:
+ frame_size = 4 * rate;
+ break;
+ case 0x40:
+ frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
+ break;
+ case 0x80:
+ frame_size = 6 * rate;
+ break;
+ default:
+ return 0;
+ }
+ } else { /// Enhanced AC-3
+ frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
+ }
+ return frame_size;
}
-int GetMLPFrameSize(const BYTE *buf)
+int GetMLPFrameSize(const BYTE* buf)
{
- DWORD sync = *(DWORD*)(buf+4);
- if (sync == TRUEHD_SYNC_WORD || sync == MLP_SYNC_WORD) {
- return (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
- }
- return 0;
+ DWORD sync = *(DWORD*)(buf + 4);
+ if (sync == TRUEHD_SYNC_WORD || sync == MLP_SYNC_WORD) {
+ return (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
+ }
+ return 0;
}
-int ParseAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framelength, int *bitrate)
+int ParseAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* bitrate)
{
- if (*(WORD*)buf != AC3_SYNC_WORD) // syncword
- return 0;
-
- if (buf[5] >> 3 >= 11) // bsid
- return 0;
-
- static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
- static const unsigned char lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
- static const unsigned char halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
-
- int frmsizecod = buf[4] & 0x3F;
- if (frmsizecod >= 38)
- return 0;
-
- int half = halfrate[buf[5] >> 3];
- int rate = rates[frmsizecod >> 1];
- *bitrate = (rate * 1000) >> half;
- int frame_size;
- switch (buf[4] & 0xc0) {
- case 0:
- *samplerate = 48000 >> half;
- frame_size = 4 * rate;
- break;
- case 0x40:
- *samplerate = 44100 >> half;
- frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
- break;
- case 0x80:
- *samplerate = 32000 >> half;
- frame_size = 6 * rate;
- break;
- default:
- return 0;
- }
-
- unsigned char acmod = buf[6] >> 5;
- unsigned char flags = ((((buf[6] & 0xf8) == 0x50) ? AC3_DOLBY : acmod) | ((buf[6] & lfeon[acmod]) ? AC3_LFE : 0));
- switch (flags & AC3_CHANNEL_MASK) {
- case AC3_MONO:
- *channels = 1;
- break;
- case AC3_CHANNEL:
- case AC3_STEREO:
- case AC3_CHANNEL1:
- case AC3_CHANNEL2:
- case AC3_DOLBY:
- *channels = 2;
- break;
- case AC3_2F1R:
- case AC3_3F:
- *channels = 3;
- break;
- case AC3_3F1R:
- case AC3_2F2R:
- *channels = 4;
- break;
- case AC3_3F2R:
- *channels = 5;
- break;
- }
- if (flags & AC3_LFE) (*channels)++;
-
- *framelength = 1536;
- return frame_size;
+ if (*(WORD*)buf != AC3_SYNC_WORD) { // syncword
+ return 0;
+ }
+
+ if (buf[5] >> 3 >= 11) { // bsid
+ return 0;
+ }
+
+ static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
+ static const unsigned char lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
+ static const unsigned char halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
+
+ int frmsizecod = buf[4] & 0x3F;
+ if (frmsizecod >= 38) {
+ return 0;
+ }
+
+ int half = halfrate[buf[5] >> 3];
+ int rate = rates[frmsizecod >> 1];
+ *bitrate = (rate * 1000) >> half;
+ int frame_size;
+ switch (buf[4] & 0xc0) {
+ case 0:
+ *samplerate = 48000 >> half;
+ frame_size = 4 * rate;
+ break;
+ case 0x40:
+ *samplerate = 44100 >> half;
+ frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
+ break;
+ case 0x80:
+ *samplerate = 32000 >> half;
+ frame_size = 6 * rate;
+ break;
+ default:
+ return 0;
+ }
+
+ unsigned char acmod = buf[6] >> 5;
+ unsigned char flags = ((((buf[6] & 0xf8) == 0x50) ? AC3_DOLBY : acmod) | ((buf[6] & lfeon[acmod]) ? AC3_LFE : 0));
+ switch (flags & AC3_CHANNEL_MASK) {
+ case AC3_MONO:
+ *channels = 1;
+ break;
+ case AC3_CHANNEL:
+ case AC3_STEREO:
+ case AC3_CHANNEL1:
+ case AC3_CHANNEL2:
+ case AC3_DOLBY:
+ *channels = 2;
+ break;
+ case AC3_2F1R:
+ case AC3_3F:
+ *channels = 3;
+ break;
+ case AC3_3F1R:
+ case AC3_2F2R:
+ *channels = 4;
+ break;
+ case AC3_3F2R:
+ *channels = 5;
+ break;
+ }
+ if (flags & AC3_LFE) { (*channels)++; }
+
+ *framelength = 1536;
+ return frame_size;
}
-int ParseEAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framelength, int *frametype)
+int ParseEAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* frametype)
{
- if (*(WORD*)buf != AC3_SYNC_WORD) // syncword
- return 0;
+ if (*(WORD*)buf != AC3_SYNC_WORD) { // syncword
+ return 0;
+ }
- if (buf[5] >> 3 <= 10) // bsid
- return 0;
+ if (buf[5] >> 3 <= 10) { // bsid
+ return 0;
+ }
- static const int sample_rates[] = { 48000, 44100, 32000, 24000, 22050, 16000 };
- static const int channels_tbl[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
- static const int samples_tbl[] = { 256, 512, 768, 1536 };
+ static const int sample_rates[] = { 48000, 44100, 32000, 24000, 22050, 16000 };
+ static const int channels_tbl[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
+ static const int samples_tbl[] = { 256, 512, 768, 1536 };
- int frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
+ int frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
- int fscod = buf[4] >> 6;
- int fscod2 = (buf[4] >> 4) & 0x03;
+ int fscod = buf[4] >> 6;
+ int fscod2 = (buf[4] >> 4) & 0x03;
- if (fscod == 0x03 && fscod2 == 0x03)
- return 0;
+ if (fscod == 0x03 && fscod2 == 0x03) {
+ return 0;
+ }
- int acmod = (buf[4] >> 1) & 0x07;
- int lfeon = buf[4] & 0x01;
+ int acmod = (buf[4] >> 1) & 0x07;
+ int lfeon = buf[4] & 0x01;
- *frametype = (buf[2] >> 6) & 0x03;
- if (*frametype == EAC3_FRAME_TYPE_RESERVED)
- return 0;
- //int sub_stream_id = (buf[2] >> 3) & 0x07;
- *samplerate = sample_rates[fscod == 0x03 ? 3 + fscod2 : fscod];
- *channels = channels_tbl[acmod] + lfeon;
- *framelength = (fscod == 0x03) ? 1536 : samples_tbl[fscod2];
+ *frametype = (buf[2] >> 6) & 0x03;
+ if (*frametype == EAC3_FRAME_TYPE_RESERVED) {
+ return 0;
+ }
+ //int sub_stream_id = (buf[2] >> 3) & 0x07;
+ *samplerate = sample_rates[fscod == 0x03 ? 3 + fscod2 : fscod];
+ *channels = channels_tbl[acmod] + lfeon;
+ *framelength = (fscod == 0x03) ? 1536 : samples_tbl[fscod2];
- return frame_size;
+ return frame_size;
}
-int ParseMLPHeader(const BYTE *buf, int *samplerate, int *channels, int *framelength, WORD *bitdepth, bool *isTrueHD)
+int ParseMLPHeader(const BYTE* buf, int* samplerate, int* channels, int* framelength, WORD* bitdepth, bool* isTrueHD)
{
- static const int sampling_rates[] = { 48000, 96000, 192000, 0, 0, 0, 0, 0, 44100, 88200, 176400, 0, 0, 0, 0, 0 };
- static const unsigned char mlp_quants[16] = { 16, 20, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- static const unsigned char mlp_channels[32] = { 1, 2, 3, 4, 3, 4, 5, 3, 4, 5, 4, 5, 6, 4, 5, 4,
- 5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- static const int channel_count[13] = {// LR C LFE LRs LRvh LRc LRrs Cs Ts LRsd LRw Cvh LFE2
- 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
- };
-
- DWORD sync = *(DWORD*)(buf+4);
- if (sync == TRUEHD_SYNC_WORD) {
- *isTrueHD = true;
- } else if (sync == MLP_SYNC_WORD) {
- *isTrueHD = false;
- } else {
- return 0;
- }
-
- int frame_size = (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
-
- if (*isTrueHD) {
- *bitdepth = 24;
- *samplerate = sampling_rates[buf[8] >> 4];
- *framelength = 40 << ((buf[8] >> 4) & 0x07);
- int chanmap_substream_1 = ((buf[ 9] & 0x0f) << 1) | (buf[10] >> 7);
- int chanmap_substream_2 = ((buf[10] & 0x1f) << 8) | buf[11];
- int channel_map = chanmap_substream_2 ? chanmap_substream_2 : chanmap_substream_1;
- *channels = 0;
- for (int i = 0; i < 13; ++i)
- *channels += channel_count[i] * ((channel_map >> i) & 1);
- } else {
- *bitdepth = mlp_quants[buf[8] >> 4];
- *samplerate = sampling_rates[buf[9] >> 4];
- *framelength = 40 << ((buf[9] >> 4) & 0x07);
- *channels = mlp_channels[buf[11] & 0x1f];
- }
-
- return frame_size;
+ static const int sampling_rates[] = { 48000, 96000, 192000, 0, 0, 0, 0, 0, 44100, 88200, 176400, 0, 0, 0, 0, 0 };
+ static const unsigned char mlp_quants[16] = { 16, 20, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ static const unsigned char mlp_channels[32] = { 1, 2, 3, 4, 3, 4, 5, 3, 4, 5, 4, 5, 6, 4, 5, 4,
+ 5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ static const int channel_count[13] = {// LR C LFE LRs LRvh LRc LRrs Cs Ts LRsd LRw Cvh LFE2
+ 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
+ };
+
+ DWORD sync = *(DWORD*)(buf + 4);
+ if (sync == TRUEHD_SYNC_WORD) {
+ *isTrueHD = true;
+ } else if (sync == MLP_SYNC_WORD) {
+ *isTrueHD = false;
+ } else {
+ return 0;
+ }
+
+ int frame_size = (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
+
+ if (*isTrueHD) {
+ *bitdepth = 24;
+ *samplerate = sampling_rates[buf[8] >> 4];
+ *framelength = 40 << ((buf[8] >> 4) & 0x07);
+ int chanmap_substream_1 = ((buf[ 9] & 0x0f) << 1) | (buf[10] >> 7);
+ int chanmap_substream_2 = ((buf[10] & 0x1f) << 8) | buf[11];
+ int channel_map = chanmap_substream_2 ? chanmap_substream_2 : chanmap_substream_1;
+ *channels = 0;
+ for (int i = 0; i < 13; ++i) {
+ *channels += channel_count[i] * ((channel_map >> i) & 1);
+ }
+ } else {
+ *bitdepth = mlp_quants[buf[8] >> 4];
+ *samplerate = sampling_rates[buf[9] >> 4];
+ *framelength = 40 << ((buf[9] >> 4) & 0x07);
+ *channels = mlp_channels[buf[11] & 0x1f];
+ }
+
+ return frame_size;
}
-int ParseHdmvLPCMHeader(const BYTE *buf, int *samplerate, int *channels)
+int ParseHdmvLPCMHeader(const BYTE* buf, int* samplerate, int* channels)
{
- *samplerate = 0;
- *channels = 0;
-
- int frame_size = buf[0] << 8 | buf[1];
- frame_size += 4; // add header size;
-
- static int channels_layout[] = {0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8, 0, 0, 0, 0};
- BYTE channel_layout = buf[2] >> 4;
- *channels = channels_layout[channel_layout];
- if (!*channels) {
- return 0;
- }
-
- static int bitspersample[] = {0, 16, 20, 24};
- int bits_per_sample = bitspersample[buf[3] >> 6];
- if (!(bits_per_sample == 16 || bits_per_sample == 24)) {
- return 0;
- }
-
- static int freq[] = {0, 48000, 0, 0, 96000, 192000};
- *samplerate = freq[buf[2] & 0x0f];
- if (!(*samplerate == 48000 || *samplerate == 96000 || *samplerate == 192000)) {
- return 0;
- }
-
- return frame_size;
+ *samplerate = 0;
+ *channels = 0;
+
+ int frame_size = buf[0] << 8 | buf[1];
+ frame_size += 4; // add header size;
+
+ static int channels_layout[] = {0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8, 0, 0, 0, 0};
+ BYTE channel_layout = buf[2] >> 4;
+ *channels = channels_layout[channel_layout];
+ if (!*channels) {
+ return 0;
+ }
+
+ static int bitspersample[] = {0, 16, 20, 24};
+ int bits_per_sample = bitspersample[buf[3] >> 6];
+ if (!(bits_per_sample == 16 || bits_per_sample == 24)) {
+ return 0;
+ }
+
+ static int freq[] = {0, 48000, 0, 0, 96000, 192000};
+ *samplerate = freq[buf[2] & 0x0f];
+ if (!(*samplerate == 48000 || *samplerate == 96000 || *samplerate == 192000)) {
+ return 0;
+ }
+
+ return frame_size;
}
DWORD GetDefChannelMask(WORD nChannels)
{
- switch (nChannels) {
- case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
- return SPEAKER_FRONT_CENTER;
- case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
- case 3: // 2.1 Stereo
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY;
- case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 5: // 5.0
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 6: // 5.1 Side (KSAUDIO_SPEAKER_5POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
- case 7: // 6.1 Side
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
- case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
- case 10: // 9.1 Surround
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_TOP_FRONT_LEFT | SPEAKER_TOP_FRONT_RIGHT;
- default:
- return 0;
- }
+ switch (nChannels) {
+ case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
+ return SPEAKER_FRONT_CENTER;
+ case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ case 3: // 2.1 Stereo
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY;
+ case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 5: // 5.0
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 6: // 5.1 Side (KSAUDIO_SPEAKER_5POINT1_SURROUND)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ case 7: // 6.1 Side
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ case 10: // 9.1 Surround
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_TOP_FRONT_LEFT | SPEAKER_TOP_FRONT_RIGHT;
+ default:
+ return 0;
+ }
}
DWORD GetVorbisChannelMask(WORD nChannels)
{
- // for Vorbis and FLAC
- // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9
- // http://flac.sourceforge.net/format.html#frame_header
- switch (nChannels) {
- case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
- return SPEAKER_FRONT_CENTER;
- case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
- case 3: // 3.0
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT;
- case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 5: // 5.0
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 6: // 5.1 (KSAUDIO_SPEAKER_5POINT1)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_LOW_FREQUENCY;
- case 7: // 6.1 Side
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_BACK_CENTER
- | SPEAKER_LOW_FREQUENCY;
- case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_LOW_FREQUENCY;
- default:
- return 0;
- }
+ // for Vorbis and FLAC
+ // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9
+ // http://flac.sourceforge.net/format.html#frame_header
+ switch (nChannels) {
+ case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
+ return SPEAKER_FRONT_CENTER;
+ case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ case 3: // 3.0
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT;
+ case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 5: // 5.0
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 6: // 5.1 (KSAUDIO_SPEAKER_5POINT1)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_LOW_FREQUENCY;
+ case 7: // 6.1 Side
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_BACK_CENTER
+ | SPEAKER_LOW_FREQUENCY;
+ case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_LOW_FREQUENCY;
+ default:
+ return 0;
+ }
}
diff --git a/src/DSUtil/AudioParser.h b/src/DSUtil/AudioParser.h
index 5213a8a3f..7b67fa098 100644
--- a/src/DSUtil/AudioParser.h
+++ b/src/DSUtil/AudioParser.h
@@ -39,13 +39,13 @@
#define EAC3_FRAME_TYPE_AC3_CONVERT 2
#define EAC3_FRAME_TYPE_RESERVED 3
-int GetAC3FrameSize(const BYTE *buf); // for AC3 and E-AC3
-int GetMLPFrameSize(const BYTE *buf); // for TrueHD and MLP
+int GetAC3FrameSize(const BYTE* buf); // for AC3 and E-AC3
+int GetMLPFrameSize(const BYTE* buf); // for TrueHD and MLP
-int ParseAC3Header (const BYTE *buf, int *samplerate, int *channels, int *framelength, int *bitrate);
-int ParseEAC3Header (const BYTE *buf, int *samplerate, int *channels, int *framelength, int *frametype);
-int ParseMLPHeader (const BYTE *buf, int *samplerate, int *channels, int *framelength, WORD *bitdepth, bool *isTrueHD); // for TrueHD and MLP
-int ParseHdmvLPCMHeader(const BYTE *buf, int *samplerate, int *channels);
+int ParseAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* bitrate);
+int ParseEAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* frametype);
+int ParseMLPHeader(const BYTE* buf, int* samplerate, int* channels, int* framelength, WORD* bitdepth, bool* isTrueHD); // for TrueHD and MLP
+int ParseHdmvLPCMHeader(const BYTE* buf, int* samplerate, int* channels);
DWORD GetDefChannelMask(WORD nChannels);
DWORD GetVorbisChannelMask(WORD nChannels);
diff --git a/src/DSUtil/DSMPropertyBag.cpp b/src/DSUtil/DSMPropertyBag.cpp
index 2ed13abfa..c292cf282 100644
--- a/src/DSUtil/DSMPropertyBag.cpp
+++ b/src/DSUtil/DSMPropertyBag.cpp
@@ -41,118 +41,118 @@ IDSMPropertyBagImpl::~IDSMPropertyBagImpl()
STDMETHODIMP IDSMPropertyBagImpl::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
{
- CheckPointer(pVar, E_POINTER);
- if (pVar->vt != VT_EMPTY) {
- return E_INVALIDARG;
- }
- CStringW value = Lookup(pszPropName);
- if (value.IsEmpty()) {
- return E_FAIL;
- }
- CComVariant(value).Detach(pVar);
- return S_OK;
+ CheckPointer(pVar, E_POINTER);
+ if (pVar->vt != VT_EMPTY) {
+ return E_INVALIDARG;
+ }
+ CStringW value = Lookup(pszPropName);
+ if (value.IsEmpty()) {
+ return E_FAIL;
+ }
+ CComVariant(value).Detach(pVar);
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::Write(LPCOLESTR pszPropName, VARIANT* pVar)
{
- return SetProperty(pszPropName, pVar);
+ return SetProperty(pszPropName, pVar);
}
// IPropertyBag2
STDMETHODIMP IDSMPropertyBagImpl::Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pvarValue, E_POINTER);
- CheckPointer(phrError, E_POINTER);
- for (ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++) {
- CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
- }
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pvarValue, E_POINTER);
+ CheckPointer(phrError, E_POINTER);
+ for (ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++) {
+ CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
+ }
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pvarValue, E_POINTER);
- for (ULONG i = 0; i < cProperties; i++) {
- SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
- }
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pvarValue, E_POINTER);
+ for (ULONG i = 0; i < cProperties; i++) {
+ SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
+ }
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::CountProperties(ULONG* pcProperties)
{
- CheckPointer(pcProperties, E_POINTER);
- *pcProperties = GetSize();
- return S_OK;
+ CheckPointer(pcProperties, E_POINTER);
+ *pcProperties = GetSize();
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pcProperties, E_POINTER);
- for (ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++) {
- CStringW key = GetKeyAt(iProperty);
- pPropBag[i].pstrName = (BSTR)CoTaskMemAlloc((key.GetLength()+1)*sizeof(WCHAR));
- if (!pPropBag[i].pstrName) {
- return E_FAIL;
- }
- wcscpy_s(pPropBag[i].pstrName, key.GetLength()+1, key);
- }
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pcProperties, E_POINTER);
+ for (ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++) {
+ CStringW key = GetKeyAt(iProperty);
+ pPropBag[i].pstrName = (BSTR)CoTaskMemAlloc((key.GetLength() + 1) * sizeof(WCHAR));
+ if (!pPropBag[i].pstrName) {
+ return E_FAIL;
+ }
+ wcscpy_s(pPropBag[i].pstrName, key.GetLength() + 1, key);
+ }
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IDSMProperyBag
HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, LPCWSTR value)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(value, E_POINTER);
- if (!Lookup(key).IsEmpty()) {
- SetAt(key, value);
- } else {
- Add(key, value);
- }
- return S_OK;
+ CheckPointer(key, E_POINTER);
+ CheckPointer(value, E_POINTER);
+ if (!Lookup(key).IsEmpty()) {
+ SetAt(key, value);
+ } else {
+ Add(key, value);
+ }
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, VARIANT* var)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(var, E_POINTER);
- if ((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) {
- return E_INVALIDARG;
- }
- return SetProperty(key, var->bstrVal);
+ CheckPointer(key, E_POINTER);
+ CheckPointer(var, E_POINTER);
+ if ((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) {
+ return E_INVALIDARG;
+ }
+ return SetProperty(key, var->bstrVal);
}
HRESULT IDSMPropertyBagImpl::GetProperty(LPCWSTR key, BSTR* value)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(value, E_POINTER);
- int i = FindKey(key);
- if (i < 0) {
- return E_FAIL;
- }
- *value = GetValueAt(i).AllocSysString();
- return S_OK;
+ CheckPointer(key, E_POINTER);
+ CheckPointer(value, E_POINTER);
+ int i = FindKey(key);
+ if (i < 0) {
+ return E_FAIL;
+ }
+ *value = GetValueAt(i).AllocSysString();
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::DelAllProperties()
{
- RemoveAll();
- return S_OK;
+ RemoveAll();
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::DelProperty(LPCWSTR key)
{
- return Remove(key) ? S_OK : S_FALSE;
+ return Remove(key) ? S_OK : S_FALSE;
}
//
@@ -163,50 +163,50 @@ CCritSec CDSMResource::m_csResources;
CAtlMap<uintptr_t, CDSMResource*> CDSMResource::m_resources;
CDSMResource::CDSMResource()
- : mime(_T("application/octet-stream"))
- , tag(0)
+ : mime(_T("application/octet-stream"))
+ , tag(0)
{
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
}
CDSMResource::CDSMResource(const CDSMResource& r)
{
- *this = r;
+ *this = r;
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
}
CDSMResource::CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag)
{
- this->name = name;
- this->desc = desc;
- this->mime = mime;
- data.SetCount(len);
- memcpy(data.GetData(), pData, data.GetCount());
- this->tag = tag;
+ this->name = name;
+ this->desc = desc;
+ this->mime = mime;
+ data.SetCount(len);
+ memcpy(data.GetData(), pData, data.GetCount());
+ this->tag = tag;
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
}
CDSMResource::~CDSMResource()
{
- CAutoLock cAutoLock(&m_csResources);
- m_resources.RemoveKey(reinterpret_cast<uintptr_t>(this));
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.RemoveKey(reinterpret_cast<uintptr_t>(this));
}
CDSMResource& CDSMResource::operator = (const CDSMResource& r)
{
- if ( this != &r ) {
- tag = r.tag;
- name = r.name;
- desc = r.desc;
- mime = r.mime;
- data.Copy(r.data);
- }
- return *this;
+ if (this != &r) {
+ tag = r.tag;
+ name = r.name;
+ desc = r.desc;
+ mime = r.mime;
+ data.Copy(r.data);
+ }
+ return *this;
}
//
@@ -221,97 +221,97 @@ IDSMResourceBagImpl::IDSMResourceBagImpl()
STDMETHODIMP_(DWORD) IDSMResourceBagImpl::ResGetCount()
{
- return (DWORD)m_resources.GetCount();
+ return (DWORD)m_resources.GetCount();
}
STDMETHODIMP IDSMResourceBagImpl::ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag)
{
- if (ppData) {
- CheckPointer(pDataLen, E_POINTER);
- }
+ if (ppData) {
+ CheckPointer(pDataLen, E_POINTER);
+ }
- if (iIndex >= m_resources.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_resources.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMResource& r = m_resources[iIndex];
+ CDSMResource& r = m_resources[iIndex];
- if (ppName) {
- *ppName = r.name.AllocSysString();
- }
- if (ppDesc) {
- *ppDesc = r.desc.AllocSysString();
- }
- if (ppMime) {
- *ppMime = r.mime.AllocSysString();
- }
- if (ppData) {
- *pDataLen = (DWORD)r.data.GetCount();
- memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);
- }
- if (pTag) {
- *pTag = r.tag;
- }
+ if (ppName) {
+ *ppName = r.name.AllocSysString();
+ }
+ if (ppDesc) {
+ *ppDesc = r.desc.AllocSysString();
+ }
+ if (ppMime) {
+ *ppMime = r.mime.AllocSysString();
+ }
+ if (ppData) {
+ *pDataLen = (DWORD)r.data.GetCount();
+ memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);
+ }
+ if (pTag) {
+ *pTag = r.tag;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- if (iIndex >= m_resources.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_resources.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMResource& r = m_resources[iIndex];
+ CDSMResource& r = m_resources[iIndex];
- if (pName) {
- r.name = pName;
- }
- if (pDesc) {
- r.desc = pDesc;
- }
- if (pMime) {
- r.mime = pMime;
- }
- if (pData || len == 0) {
- r.data.SetCount(len);
- if (pData) {
- memcpy(r.data.GetData(), pData, r.data.GetCount());
- }
- }
- r.tag = tag;
+ if (pName) {
+ r.name = pName;
+ }
+ if (pDesc) {
+ r.desc = pDesc;
+ }
+ if (pMime) {
+ r.mime = pMime;
+ }
+ if (pData || len == 0) {
+ r.data.SetCount(len);
+ if (pData) {
+ memcpy(r.data.GetData(), pData, r.data.GetCount());
+ }
+ }
+ r.tag = tag;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- return ResSet((DWORD)m_resources.Add(CDSMResource()), pName, pDesc, pMime, pData, len, tag);
+ return ResSet((DWORD)m_resources.Add(CDSMResource()), pName, pDesc, pMime, pData, len, tag);
}
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAt(DWORD iIndex)
{
- if (iIndex >= m_resources.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_resources.GetCount()) {
+ return E_INVALIDARG;
+ }
- m_resources.RemoveAt(iIndex);
+ m_resources.RemoveAt(iIndex);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
{
- if (tag) {
- for (ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
- if (m_resources[i].tag == tag) {
- m_resources.RemoveAt(i);
- }
- } else {
- m_resources.RemoveAll();
- }
+ if (tag) {
+ for (ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
+ if (m_resources[i].tag == tag) {
+ m_resources.RemoveAt(i);
+ }
+ } else {
+ m_resources.RemoveAll();
+ }
- return S_OK;
+ return S_OK;
}
//
@@ -320,41 +320,41 @@ STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
CDSMChapter::CDSMChapter()
{
- order = counter++;
- rt = 0;
+ order = counter++;
+ rt = 0;
}
CDSMChapter::CDSMChapter(REFERENCE_TIME rt, LPCWSTR name)
{
- order = counter++;
- this->rt = rt;
- this->name = name;
+ order = counter++;
+ this->rt = rt;
+ this->name = name;
}
CDSMChapter& CDSMChapter::operator = (const CDSMChapter& c)
{
- if ( this != &c ) {
- order = c.counter;
- rt = c.rt;
- name = c.name;
- }
- return *this;
+ if (this != &c) {
+ order = c.counter;
+ rt = c.rt;
+ name = c.name;
+ }
+ return *this;
}
int CDSMChapter::counter = 0;
int CDSMChapter::Compare(const void* a, const void* b)
{
- const CDSMChapter* ca = static_cast<const CDSMChapter*>(a);
- const CDSMChapter* cb = static_cast<const CDSMChapter*>(b);
+ const CDSMChapter* ca = static_cast<const CDSMChapter*>(a);
+ const CDSMChapter* cb = static_cast<const CDSMChapter*>(b);
- if (ca->rt > cb->rt) {
- return 1;
- } else if (ca->rt < cb->rt) {
- return -1;
- }
+ if (ca->rt > cb->rt) {
+ return 1;
+ } else if (ca->rt < cb->rt) {
+ return -1;
+ }
- return ca->order - cb->order;
+ return ca->order - cb->order;
}
//
@@ -363,104 +363,104 @@ int CDSMChapter::Compare(const void* a, const void* b)
IDSMChapterBagImpl::IDSMChapterBagImpl()
{
- m_fSorted = false;
+ m_fSorted = false;
}
// IDSMRChapterBag
STDMETHODIMP_(DWORD) IDSMChapterBagImpl::ChapGetCount()
{
- return (DWORD)m_chapters.GetCount();
+ return (DWORD)m_chapters.GetCount();
}
STDMETHODIMP IDSMChapterBagImpl::ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName)
{
- if (iIndex >= m_chapters.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_chapters.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMChapter& c = m_chapters[iIndex];
+ CDSMChapter& c = m_chapters[iIndex];
- if (prt) {
- *prt = c.rt;
- }
- if (ppName) {
- *ppName = c.name.AllocSysString();
- }
+ if (prt) {
+ *prt = c.rt;
+ }
+ if (ppName) {
+ *ppName = c.name.AllocSysString();
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName)
{
- if (iIndex >= m_chapters.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_chapters.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMChapter& c = m_chapters[iIndex];
+ CDSMChapter& c = m_chapters[iIndex];
- c.rt = rt;
- if (pName) {
- c.name = pName;
- }
+ c.rt = rt;
+ if (pName) {
+ c.name = pName;
+ }
- m_fSorted = false;
+ m_fSorted = false;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapAppend(REFERENCE_TIME rt, LPCWSTR pName)
{
- return ChapSet((DWORD)m_chapters.Add(CDSMChapter()), rt, pName);
+ return ChapSet((DWORD)m_chapters.Add(CDSMChapter()), rt, pName);
}
STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAt(DWORD iIndex)
{
- if (iIndex >= m_chapters.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_chapters.GetCount()) {
+ return E_INVALIDARG;
+ }
- m_chapters.RemoveAt(iIndex);
+ m_chapters.RemoveAt(iIndex);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAll()
{
- m_chapters.RemoveAll();
+ m_chapters.RemoveAll();
- m_fSorted = false;
+ m_fSorted = false;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(long) IDSMChapterBagImpl::ChapLookup(REFERENCE_TIME* prt, BSTR* ppName)
{
- CheckPointer(prt, -1);
+ CheckPointer(prt, -1);
- ChapSort();
+ ChapSort();
- ptrdiff_t i = range_bsearch(m_chapters, *prt);
- if (i < 0) {
- return -1;
- }
+ ptrdiff_t i = range_bsearch(m_chapters, *prt);
+ if (i < 0) {
+ return -1;
+ }
- *prt = m_chapters[i].rt;
- if (ppName) {
- *ppName = m_chapters[i].name.AllocSysString();
- }
+ *prt = m_chapters[i].rt;
+ if (ppName) {
+ *ppName = m_chapters[i].name.AllocSysString();
+ }
- return (long)i;
+ return (long)i;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSort()
{
- if (m_fSorted) {
- return S_FALSE;
- }
- qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
- m_fSorted = true;
- return S_OK;
+ if (m_fSorted) {
+ return S_FALSE;
+ }
+ qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
+ m_fSorted = true;
+ return S_OK;
}
//
@@ -468,15 +468,15 @@ STDMETHODIMP IDSMChapterBagImpl::ChapSort()
//
CDSMChapterBag::CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr)
- : CUnknown(_T("CDSMChapterBag"), NULL)
+ : CUnknown(_T("CDSMChapterBag"), NULL)
{
}
STDMETHODIMP CDSMChapterBag::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IDSMChapterBag)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IDSMChapterBag)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
diff --git a/src/DSUtil/DSMPropertyBag.h b/src/DSUtil/DSMPropertyBag.h
index 3a6e5c825..61f97a37f 100644
--- a/src/DSUtil/DSMPropertyBag.h
+++ b/src/DSUtil/DSMPropertyBag.h
@@ -30,46 +30,46 @@
interface __declspec(uuid("232FD5D2-4954-41E7-BF9B-09E1257B1A95"))
IDSMPropertyBag :
public IPropertyBag2 {
- STDMETHOD(SetProperty) (LPCWSTR key, LPCWSTR value) = 0;
- STDMETHOD(SetProperty) (LPCWSTR key, VARIANT* var) = 0;
- STDMETHOD(GetProperty) (LPCWSTR key, BSTR* value) = 0;
- STDMETHOD(DelAllProperties) () = 0;
- STDMETHOD(DelProperty) (LPCWSTR key) = 0;
+ STDMETHOD(SetProperty)(LPCWSTR key, LPCWSTR value) = 0;
+ STDMETHOD(SetProperty)(LPCWSTR key, VARIANT * var) = 0;
+ STDMETHOD(GetProperty)(LPCWSTR key, BSTR * value) = 0;
+ STDMETHOD(DelAllProperties)() = 0;
+ STDMETHOD(DelProperty)(LPCWSTR key) = 0;
};
class IDSMPropertyBagImpl : public ATL::CSimpleMap<CStringW, CStringW>, public IDSMPropertyBag, public IPropertyBag
{
- BOOL Add(const CStringW& key, const CStringW& val) {
- return __super::Add(key, val);
- }
- BOOL SetAt(const CStringW& key, const CStringW& val) {
- return __super::SetAt(key, val);
- }
+ BOOL Add(const CStringW& key, const CStringW& val) {
+ return __super::Add(key, val);
+ }
+ BOOL SetAt(const CStringW& key, const CStringW& val) {
+ return __super::SetAt(key, val);
+ }
public:
- IDSMPropertyBagImpl();
- virtual ~IDSMPropertyBagImpl();
+ IDSMPropertyBagImpl();
+ virtual ~IDSMPropertyBagImpl();
- // IPropertyBag
+ // IPropertyBag
- STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
- STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT* pVar);
+ STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
+ STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT* pVar);
- // IPropertyBag2
+ // IPropertyBag2
- STDMETHODIMP Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError);
- STDMETHODIMP Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue);
- STDMETHODIMP CountProperties(ULONG* pcProperties);
- STDMETHODIMP GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties);
- STDMETHODIMP LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog);
+ STDMETHODIMP Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError);
+ STDMETHODIMP Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue);
+ STDMETHODIMP CountProperties(ULONG* pcProperties);
+ STDMETHODIMP GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties);
+ STDMETHODIMP LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog);
- // IDSMPropertyBag
+ // IDSMPropertyBag
- STDMETHODIMP SetProperty(LPCWSTR key, LPCWSTR value);
- STDMETHODIMP SetProperty(LPCWSTR key, VARIANT* var);
- STDMETHODIMP GetProperty(LPCWSTR key, BSTR* value);
- STDMETHODIMP DelAllProperties();
- STDMETHODIMP DelProperty(LPCWSTR key);
+ STDMETHODIMP SetProperty(LPCWSTR key, LPCWSTR value);
+ STDMETHODIMP SetProperty(LPCWSTR key, VARIANT* var);
+ STDMETHODIMP GetProperty(LPCWSTR key, BSTR* value);
+ STDMETHODIMP DelAllProperties();
+ STDMETHODIMP DelProperty(LPCWSTR key);
};
// IDSMResourceBag
@@ -77,49 +77,49 @@ public:
interface __declspec(uuid("EBAFBCBE-BDE0-489A-9789-05D5692E3A93"))
IDSMResourceBag :
public IUnknown {
- STDMETHOD_(DWORD, ResGetCount) () = 0;
- STDMETHOD(ResGet) (DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag) = 0;
- STDMETHOD(ResSet) (DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
- STDMETHOD(ResAppend) (LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
- STDMETHOD(ResRemoveAt) (DWORD iIndex) = 0;
- STDMETHOD(ResRemoveAll) (DWORD_PTR tag) = 0;
+ STDMETHOD_(DWORD, ResGetCount)() = 0;
+ STDMETHOD(ResGet)(DWORD iIndex, BSTR * ppName, BSTR * ppDesc, BSTR * ppMime, BYTE** ppData, DWORD * pDataLen, DWORD_PTR * pTag) = 0;
+ STDMETHOD(ResSet)(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE * pData, DWORD len, DWORD_PTR tag) = 0;
+ STDMETHOD(ResAppend)(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE * pData, DWORD len, DWORD_PTR tag) = 0;
+ STDMETHOD(ResRemoveAt)(DWORD iIndex) = 0;
+ STDMETHOD(ResRemoveAll)(DWORD_PTR tag) = 0;
};
class CDSMResource
{
public:
- DWORD_PTR tag;
- CStringW name, desc, mime;
- CAtlArray<BYTE> data;
- CDSMResource();
- CDSMResource(const CDSMResource& r);
- CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag = 0);
- virtual ~CDSMResource();
- CDSMResource& operator = (const CDSMResource& r);
-
- // global access to all resources
- static CCritSec m_csResources;
- static CAtlMap<uintptr_t, CDSMResource*> m_resources;
+ DWORD_PTR tag;
+ CStringW name, desc, mime;
+ CAtlArray<BYTE> data;
+ CDSMResource();
+ CDSMResource(const CDSMResource& r);
+ CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag = 0);
+ virtual ~CDSMResource();
+ CDSMResource& operator = (const CDSMResource& r);
+
+ // global access to all resources
+ static CCritSec m_csResources;
+ static CAtlMap<uintptr_t, CDSMResource*> m_resources;
};
class IDSMResourceBagImpl : public IDSMResourceBag
{
protected:
- CAtlArray<CDSMResource> m_resources;
+ CAtlArray<CDSMResource> m_resources;
public:
- IDSMResourceBagImpl();
+ IDSMResourceBagImpl();
- void operator += (const CDSMResource& r) { m_resources.Add(r); }
+ void operator += (const CDSMResource& r) { m_resources.Add(r); }
- // IDSMResourceBag
+ // IDSMResourceBag
- STDMETHODIMP_(DWORD) ResGetCount();
- STDMETHODIMP ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag = NULL);
- STDMETHODIMP ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
- STDMETHODIMP ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
- STDMETHODIMP ResRemoveAt(DWORD iIndex);
- STDMETHODIMP ResRemoveAll(DWORD_PTR tag = 0);
+ STDMETHODIMP_(DWORD) ResGetCount();
+ STDMETHODIMP ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag = NULL);
+ STDMETHODIMP ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
+ STDMETHODIMP ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
+ STDMETHODIMP ResRemoveAt(DWORD iIndex);
+ STDMETHODIMP ResRemoveAll(DWORD_PTR tag = 0);
};
// IDSMChapterBag
@@ -127,88 +127,88 @@ public:
interface __declspec(uuid("2D0EBE73-BA82-4E90-859B-C7C48ED3650F"))
IDSMChapterBag :
public IUnknown {
- STDMETHOD_(DWORD, ChapGetCount) () = 0;
- STDMETHOD(ChapGet) (DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName) = 0;
- STDMETHOD(ChapSet) (DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName) = 0;
- STDMETHOD(ChapAppend) (REFERENCE_TIME rt, LPCWSTR pName) = 0;
- STDMETHOD(ChapRemoveAt) (DWORD iIndex) = 0;
- STDMETHOD(ChapRemoveAll) () = 0;
- STDMETHOD_(long, ChapLookup) (REFERENCE_TIME* prt, BSTR* ppName) = 0;
- STDMETHOD(ChapSort) () = 0;
+ STDMETHOD_(DWORD, ChapGetCount)() = 0;
+ STDMETHOD(ChapGet)(DWORD iIndex, REFERENCE_TIME * prt, BSTR * ppName) = 0;
+ STDMETHOD(ChapSet)(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName) = 0;
+ STDMETHOD(ChapAppend)(REFERENCE_TIME rt, LPCWSTR pName) = 0;
+ STDMETHOD(ChapRemoveAt)(DWORD iIndex) = 0;
+ STDMETHOD(ChapRemoveAll)() = 0;
+ STDMETHOD_(long, ChapLookup)(REFERENCE_TIME * prt, BSTR * ppName) = 0;
+ STDMETHOD(ChapSort)() = 0;
};
class CDSMChapter
{
- static int counter;
- int order;
+ static int counter;
+ int order;
public:
- REFERENCE_TIME rt;
- CStringW name;
- CDSMChapter();
- CDSMChapter(REFERENCE_TIME rt, LPCWSTR name);
- CDSMChapter& operator = (const CDSMChapter& c);
- static int Compare(const void* a, const void* b);
+ REFERENCE_TIME rt;
+ CStringW name;
+ CDSMChapter();
+ CDSMChapter(REFERENCE_TIME rt, LPCWSTR name);
+ CDSMChapter& operator = (const CDSMChapter& c);
+ static int Compare(const void* a, const void* b);
};
class IDSMChapterBagImpl : public IDSMChapterBag
{
protected:
- CAtlArray<CDSMChapter> m_chapters;
- bool m_fSorted;
+ CAtlArray<CDSMChapter> m_chapters;
+ bool m_fSorted;
public:
- IDSMChapterBagImpl();
+ IDSMChapterBagImpl();
- void operator += (const CDSMChapter& c) { m_chapters.Add(c); m_fSorted = false; }
+ void operator += (const CDSMChapter& c) { m_chapters.Add(c); m_fSorted = false; }
- // IDSMChapterBag
+ // IDSMChapterBag
- STDMETHODIMP_(DWORD) ChapGetCount();
- STDMETHODIMP ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName = NULL);
- STDMETHODIMP ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName);
- STDMETHODIMP ChapAppend(REFERENCE_TIME rt, LPCWSTR pName);
- STDMETHODIMP ChapRemoveAt(DWORD iIndex);
- STDMETHODIMP ChapRemoveAll();
- STDMETHODIMP_(long) ChapLookup(REFERENCE_TIME* prt, BSTR* ppName = NULL);
- STDMETHODIMP ChapSort();
+ STDMETHODIMP_(DWORD) ChapGetCount();
+ STDMETHODIMP ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName = NULL);
+ STDMETHODIMP ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName);
+ STDMETHODIMP ChapAppend(REFERENCE_TIME rt, LPCWSTR pName);
+ STDMETHODIMP ChapRemoveAt(DWORD iIndex);
+ STDMETHODIMP ChapRemoveAll();
+ STDMETHODIMP_(long) ChapLookup(REFERENCE_TIME* prt, BSTR* ppName = NULL);
+ STDMETHODIMP ChapSort();
};
class CDSMChapterBag : public CUnknown, public IDSMChapterBagImpl
{
public:
- CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr);
+ CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
template<class T>
-ptrdiff_t range_bsearch(CAtlArray<T> const &tArray, REFERENCE_TIME rt)
+ptrdiff_t range_bsearch(CAtlArray<T> const& tArray, REFERENCE_TIME rt)
{
- ptrdiff_t i = 0, j = tArray.GetCount() - 1, ret = -1;
- if (j >= 0 && rt >= tArray[j].rt) {
- return j;
- }
- while (i < j) {
- size_t mid = static_cast<size_t>(i + j) >> 1;
- REFERENCE_TIME midrt = tArray[mid].rt;
- if (rt == midrt) {
- ret = mid;
- break;
- } else if (rt < midrt) {
- ret = -1;
- if (j == mid) {
- --mid;
- }
- j = mid;
- } else if (rt > midrt) {
- ret = mid;
- if (i == mid) {
- ++mid;
- }
- i = mid;
- }
- }
- return ret;// in general, the return is unsigned, only when tArray is empty, the return will be -1 for status invalid
+ ptrdiff_t i = 0, j = tArray.GetCount() - 1, ret = -1;
+ if (j >= 0 && rt >= tArray[j].rt) {
+ return j;
+ }
+ while (i < j) {
+ size_t mid = static_cast<size_t>(i + j) >> 1;
+ REFERENCE_TIME midrt = tArray[mid].rt;
+ if (rt == midrt) {
+ ret = mid;
+ break;
+ } else if (rt < midrt) {
+ ret = -1;
+ if (j == mid) {
+ --mid;
+ }
+ j = mid;
+ } else if (rt > midrt) {
+ ret = mid;
+ if (i == mid) {
+ ++mid;
+ }
+ i = mid;
+ }
+ }
+ return ret;// in general, the return is unsigned, only when tArray is empty, the return will be -1 for status invalid
}
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp
index e5231f3c5..d9ab6bd08 100644
--- a/src/DSUtil/DSUtil.cpp
+++ b/src/DSUtil/DSUtil.cpp
@@ -38,2594 +38,2577 @@
void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
{
- CString s;
- CStdioFile f;
- if (!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) {
- return;
- }
-
- int cnt = 0, size = 0;
- if (FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size))) {
- return;
- }
-
- s.Format(_T("cnt %d, size %d\n"), cnt, size);
- f.WriteString(s);
-
- if (size == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
- for (int i = 0; i < cnt; i++) {
- AM_MEDIA_TYPE* pmt = NULL;
-
- VIDEO_STREAM_CONFIG_CAPS caps;
- memset(&caps, 0, sizeof(caps));
-
- s.Format(_T("%d\n"), i);
- f.WriteString(s);
-
- if (FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
- continue;
- }
-
- {
- s = _T("VIDEO_STREAM_CONFIG_CAPS\n");
- s.AppendFormat(_T("\tVideoStandard 0x%08x\n"), caps.VideoStandard);
- s.AppendFormat(_T("\tInputSize %dx%d\n"), caps.InputSize);
- s.AppendFormat(_T("\tCroppingSize %dx%d - %dx%d\n"), caps.MinCroppingSize, caps.MaxCroppingSize);
- s.AppendFormat(_T("\tCropGranularity %d, %d\n"), caps.CropGranularityX, caps.CropGranularityY);
- s.AppendFormat(_T("\tCropAlign %d, %d\n"), caps.CropAlignX, caps.CropAlignY);
- s.AppendFormat(_T("\tOutputSize %dx%d - %dx%d\n"), caps.MinOutputSize, caps.MaxOutputSize);
- s.AppendFormat(_T("\tOutputGranularity %d, %d\n"), caps.OutputGranularityX, caps.OutputGranularityY);
- s.AppendFormat(_T("\tStretchTaps %d, %d\n"), caps.StretchTapsX, caps.StretchTapsY);
- s.AppendFormat(_T("\tShrinkTaps %d, %d\n"), caps.ShrinkTapsX, caps.ShrinkTapsY);
- s.AppendFormat(_T("\tFrameInterval %I64d, %I64d (%.4f, %.4f)\n"),
- caps.MinFrameInterval, caps.MaxFrameInterval,
- (float)10000000/caps.MinFrameInterval, (float)10000000/caps.MaxFrameInterval);
- s.AppendFormat(_T("\tBitsPerSecond %d - %d\n"), caps.MinBitsPerSecond, caps.MaxBitsPerSecond);
- f.WriteString(s);
- }
-
- BITMAPINFOHEADER* pbh;
- if (pmt->formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- pbh = &vih->bmiHeader;
-
- s = _T("FORMAT_VideoInfo\n");
- s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000/vih->AvgTimePerFrame);
- s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
- s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
- f.WriteString(s);
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- pbh = &vih->bmiHeader;
-
- s = _T("FORMAT_VideoInfo2\n");
- s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000/vih->AvgTimePerFrame);
- s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
- s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
- s.AppendFormat(_T("\tdwInterlaceFlags 0x%x\n"), vih->dwInterlaceFlags);
- s.AppendFormat(_T("\tdwPictAspectRatio %d:%d\n"), vih->dwPictAspectRatioX, vih->dwPictAspectRatioY);
- f.WriteString(s);
- } else {
- DeleteMediaType(pmt);
- continue;
- }
-
- s = _T("BITMAPINFOHEADER\n");
- s.AppendFormat(_T("\tbiCompression %x\n"), pbh->biCompression);
- s.AppendFormat(_T("\tbiWidth %d\n"), pbh->biWidth);
- s.AppendFormat(_T("\tbiHeight %d\n"), pbh->biHeight);
- s.AppendFormat(_T("\tbiBitCount %d\n"), pbh->biBitCount);
- s.AppendFormat(_T("\tbiPlanes %d\n"), pbh->biPlanes);
- s.AppendFormat(_T("\tbiSizeImage %d\n"), pbh->biSizeImage);
- f.WriteString(s);
-
- DeleteMediaType(pmt);
- }
- } else if (size == sizeof(AUDIO_STREAM_CONFIG_CAPS)) {
- // TODO
- }
+ CString s;
+ CStdioFile f;
+ if (!f.Open(fn, CFile::modeCreate | CFile::modeWrite | CFile::typeText)) {
+ return;
+ }
+
+ int cnt = 0, size = 0;
+ if (FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size))) {
+ return;
+ }
+
+ s.Format(_T("cnt %d, size %d\n"), cnt, size);
+ f.WriteString(s);
+
+ if (size == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
+ for (int i = 0; i < cnt; i++) {
+ AM_MEDIA_TYPE* pmt = NULL;
+
+ VIDEO_STREAM_CONFIG_CAPS caps;
+ memset(&caps, 0, sizeof(caps));
+
+ s.Format(_T("%d\n"), i);
+ f.WriteString(s);
+
+ if (FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
+ continue;
+ }
+
+ {
+ s = _T("VIDEO_STREAM_CONFIG_CAPS\n");
+ s.AppendFormat(_T("\tVideoStandard 0x%08x\n"), caps.VideoStandard);
+ s.AppendFormat(_T("\tInputSize %dx%d\n"), caps.InputSize);
+ s.AppendFormat(_T("\tCroppingSize %dx%d - %dx%d\n"), caps.MinCroppingSize, caps.MaxCroppingSize);
+ s.AppendFormat(_T("\tCropGranularity %d, %d\n"), caps.CropGranularityX, caps.CropGranularityY);
+ s.AppendFormat(_T("\tCropAlign %d, %d\n"), caps.CropAlignX, caps.CropAlignY);
+ s.AppendFormat(_T("\tOutputSize %dx%d - %dx%d\n"), caps.MinOutputSize, caps.MaxOutputSize);
+ s.AppendFormat(_T("\tOutputGranularity %d, %d\n"), caps.OutputGranularityX, caps.OutputGranularityY);
+ s.AppendFormat(_T("\tStretchTaps %d, %d\n"), caps.StretchTapsX, caps.StretchTapsY);
+ s.AppendFormat(_T("\tShrinkTaps %d, %d\n"), caps.ShrinkTapsX, caps.ShrinkTapsY);
+ s.AppendFormat(_T("\tFrameInterval %I64d, %I64d (%.4f, %.4f)\n"),
+ caps.MinFrameInterval, caps.MaxFrameInterval,
+ (float)10000000 / caps.MinFrameInterval, (float)10000000 / caps.MaxFrameInterval);
+ s.AppendFormat(_T("\tBitsPerSecond %d - %d\n"), caps.MinBitsPerSecond, caps.MaxBitsPerSecond);
+ f.WriteString(s);
+ }
+
+ BITMAPINFOHEADER* pbh;
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ pbh = &vih->bmiHeader;
+
+ s = _T("FORMAT_VideoInfo\n");
+ s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000 / vih->AvgTimePerFrame);
+ s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
+ s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
+ f.WriteString(s);
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ pbh = &vih->bmiHeader;
+
+ s = _T("FORMAT_VideoInfo2\n");
+ s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000 / vih->AvgTimePerFrame);
+ s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
+ s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
+ s.AppendFormat(_T("\tdwInterlaceFlags 0x%x\n"), vih->dwInterlaceFlags);
+ s.AppendFormat(_T("\tdwPictAspectRatio %d:%d\n"), vih->dwPictAspectRatioX, vih->dwPictAspectRatioY);
+ f.WriteString(s);
+ } else {
+ DeleteMediaType(pmt);
+ continue;
+ }
+
+ s = _T("BITMAPINFOHEADER\n");
+ s.AppendFormat(_T("\tbiCompression %x\n"), pbh->biCompression);
+ s.AppendFormat(_T("\tbiWidth %d\n"), pbh->biWidth);
+ s.AppendFormat(_T("\tbiHeight %d\n"), pbh->biHeight);
+ s.AppendFormat(_T("\tbiBitCount %d\n"), pbh->biBitCount);
+ s.AppendFormat(_T("\tbiPlanes %d\n"), pbh->biPlanes);
+ s.AppendFormat(_T("\tbiSizeImage %d\n"), pbh->biSizeImage);
+ f.WriteString(s);
+
+ DeleteMediaType(pmt);
+ }
+ } else if (size == sizeof(AUDIO_STREAM_CONFIG_CAPS)) {
+ // TODO
+ }
}
int CountPins(IBaseFilter* pBF, int& nIn, int& nOut, int& nInC, int& nOutC)
{
- nIn = nOut = 0;
- nInC = nOutC = 0;
-
- BeginEnumPins(pBF, pEP, pPin) {
- PIN_DIRECTION dir;
- if (SUCCEEDED(pPin->QueryDirection(&dir))) {
- CComPtr<IPin> pPinConnectedTo;
- pPin->ConnectedTo(&pPinConnectedTo);
-
- if (dir == PINDIR_INPUT) {
- nIn++;
- if (pPinConnectedTo) {
- nInC++;
- }
- } else if (dir == PINDIR_OUTPUT) {
- nOut++;
- if (pPinConnectedTo) {
- nOutC++;
- }
- }
- }
- }
- EndEnumPins
-
- return (nIn + nOut);
+ nIn = nOut = 0;
+ nInC = nOutC = 0;
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ PIN_DIRECTION dir;
+ if (SUCCEEDED(pPin->QueryDirection(&dir))) {
+ CComPtr<IPin> pPinConnectedTo;
+ pPin->ConnectedTo(&pPinConnectedTo);
+
+ if (dir == PINDIR_INPUT) {
+ nIn++;
+ if (pPinConnectedTo) {
+ nInC++;
+ }
+ } else if (dir == PINDIR_OUTPUT) {
+ nOut++;
+ if (pPinConnectedTo) {
+ nOutC++;
+ }
+ }
+ }
+ }
+ EndEnumPins
+
+ return (nIn + nOut);
}
bool IsSplitter(IBaseFilter* pBF, bool fCountConnectedOnly)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return (fCountConnectedOnly ? nOutC > 1 : nOut > 1);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return (fCountConnectedOnly ? nOutC > 1 : nOut > 1);
}
bool IsMultiplexer(IBaseFilter* pBF, bool fCountConnectedOnly)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return (fCountConnectedOnly ? nInC > 1 : nIn > 1);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return (fCountConnectedOnly ? nInC > 1 : nIn > 1);
}
bool IsStreamStart(IBaseFilter* pBF)
{
- CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if (pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE) {
- return true;
- }
+ CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
+ if (pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE) {
+ return true;
+ }
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- AM_MEDIA_TYPE mt;
- CComPtr<IPin> pIn = GetFirstPin(pBF);
- return ((nOut > 1)
- || (nOut > 0 && nIn == 1 && pIn && SUCCEEDED(pIn->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream));
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ AM_MEDIA_TYPE mt;
+ CComPtr<IPin> pIn = GetFirstPin(pBF);
+ return ((nOut > 1)
+ || (nOut > 0 && nIn == 1 && pIn && SUCCEEDED(pIn->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream));
}
bool IsStreamEnd(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return (nOut == 0);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return (nOut == 0);
}
bool IsVideoRenderer(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
- if (nInC > 0 && nOut == 0) {
- BeginEnumPins(pBF, pEP, pPin) {
- AM_MEDIA_TYPE mt;
- if (S_OK != pPin->ConnectionMediaType(&mt)) {
- continue;
- }
+ if (nInC > 0 && nOut == 0) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ AM_MEDIA_TYPE mt;
+ if (S_OK != pPin->ConnectionMediaType(&mt)) {
+ continue;
+ }
- FreeMediaType(mt);
+ FreeMediaType(mt);
- return !!(mt.majortype == MEDIATYPE_Video);
- /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
- }
- EndEnumPins
- }
+ return !!(mt.majortype == MEDIATYPE_Video);
+ /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
+ }
+ EndEnumPins
+ }
- CLSID clsid;
- memcpy(&clsid, &GUID_NULL, sizeof(clsid));
- pBF->GetClassID(&clsid);
+ CLSID clsid;
+ memcpy(&clsid, &GUID_NULL, sizeof(clsid));
+ pBF->GetClassID(&clsid);
- return (clsid == CLSID_VideoRenderer || clsid == CLSID_VideoRendererDefault);
+ return (clsid == CLSID_VideoRenderer || clsid == CLSID_VideoRendererDefault);
}
DEFINE_GUID(CLSID_ReClock,
- 0x9dc15360, 0x914c, 0x46b8, 0xb9, 0xdf, 0xbf, 0xe6, 0x7f, 0xd3, 0x6c, 0x6a);
+ 0x9dc15360, 0x914c, 0x46b8, 0xb9, 0xdf, 0xbf, 0xe6, 0x7f, 0xd3, 0x6c, 0x6a);
bool IsAudioWaveRenderer(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
- if (nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF)) {
- BeginEnumPins(pBF, pEP, pPin) {
- AM_MEDIA_TYPE mt;
- if (S_OK != pPin->ConnectionMediaType(&mt)) {
- continue;
- }
+ if (nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF)) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ AM_MEDIA_TYPE mt;
+ if (S_OK != pPin->ConnectionMediaType(&mt)) {
+ continue;
+ }
- FreeMediaType(mt);
+ FreeMediaType(mt);
- return !!(mt.majortype == MEDIATYPE_Audio);
- /*&& mt.formattype == FORMAT_WaveFormatEx);*/
- }
- EndEnumPins
- }
+ return !!(mt.majortype == MEDIATYPE_Audio);
+ /*&& mt.formattype == FORMAT_WaveFormatEx);*/
+ }
+ EndEnumPins
+ }
- CLSID clsid;
- memcpy(&clsid, &GUID_NULL, sizeof(clsid));
- pBF->GetClassID(&clsid);
+ CLSID clsid;
+ memcpy(&clsid, &GUID_NULL, sizeof(clsid));
+ pBF->GetClassID(&clsid);
- return (clsid == CLSID_DSoundRender || clsid == CLSID_AudioRender || clsid == CLSID_ReClock
- || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
+ return (clsid == CLSID_DSoundRender || clsid == CLSID_AudioRender || clsid == CLSID_ReClock
+ || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
}
IBaseFilter* GetUpStreamFilter(IBaseFilter* pBF, IPin* pInputPin)
{
- return GetFilterFromPin(GetUpStreamPin(pBF, pInputPin));
+ return GetFilterFromPin(GetUpStreamPin(pBF, pInputPin));
}
IPin* GetUpStreamPin(IBaseFilter* pBF, IPin* pInputPin)
{
- BeginEnumPins(pBF, pEP, pPin) {
- if (pInputPin && pInputPin != pPin) {
- continue;
- }
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (pInputPin && pInputPin != pPin) {
+ continue;
+ }
- PIN_DIRECTION dir;
- CComPtr<IPin> pPinConnectedTo;
- if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
- && SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo))) {
- IPin* pRet = pPinConnectedTo.Detach();
- pRet->Release();
- return pRet;
- }
- }
- EndEnumPins
+ PIN_DIRECTION dir;
+ CComPtr<IPin> pPinConnectedTo;
+ if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
+ && SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo))) {
+ IPin* pRet = pPinConnectedTo.Detach();
+ pRet->Release();
+ return pRet;
+ }
+ }
+ EndEnumPins
- return NULL;
+ return NULL;
}
IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if (!pBF) {
- return NULL;
- }
+ if (!pBF) {
+ return NULL;
+ }
- BeginEnumPins(pBF, pEP, pPin) {
- PIN_DIRECTION dir2;
- pPin->QueryDirection(&dir2);
- if (dir == dir2) {
- IPin* pRet = pPin.Detach();
- pRet->Release();
- return pRet;
- }
- }
- EndEnumPins
+ BeginEnumPins(pBF, pEP, pPin) {
+ PIN_DIRECTION dir2;
+ pPin->QueryDirection(&dir2);
+ if (dir == dir2) {
+ IPin* pRet = pPin.Detach();
+ pRet->Release();
+ return pRet;
+ }
+ }
+ EndEnumPins
- return NULL;
+ return NULL;
}
IPin* GetFirstDisconnectedPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if (!pBF) {
- return NULL;
- }
+ if (!pBF) {
+ return NULL;
+ }
- BeginEnumPins(pBF, pEP, pPin) {
- PIN_DIRECTION dir2;
- pPin->QueryDirection(&dir2);
- CComPtr<IPin> pPinTo;
- if (dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo))) {
- IPin* pRet = pPin.Detach();
- pRet->Release();
- return pRet;
- }
- }
- EndEnumPins
+ BeginEnumPins(pBF, pEP, pPin) {
+ PIN_DIRECTION dir2;
+ pPin->QueryDirection(&dir2);
+ CComPtr<IPin> pPinTo;
+ if (dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo))) {
+ IPin* pRet = pPin.Detach();
+ pRet->Release();
+ return pRet;
+ }
+ }
+ EndEnumPins
- return NULL;
+ return NULL;
}
IBaseFilter* FindFilter(LPCWSTR clsid, IFilterGraph* pFG)
{
- CLSID clsid2;
- CLSIDFromString(CComBSTR(clsid), &clsid2);
- return FindFilter(clsid2, pFG);
+ CLSID clsid2;
+ CLSIDFromString(CComBSTR(clsid), &clsid2);
+ return FindFilter(clsid2, pFG);
}
IBaseFilter* FindFilter(const CLSID& clsid, IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF) {
- CLSID clsid2;
- if (SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2) {
- return pBF;
- }
- }
- EndEnumFilters
+ BeginEnumFilters(pFG, pEF, pBF) {
+ CLSID clsid2;
+ if (SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2) {
+ return pBF;
+ }
+ }
+ EndEnumFilters
- return NULL;
+ return NULL;
}
IPin* FindPin(IBaseFilter* pBF, PIN_DIRECTION direction, const AM_MEDIA_TYPE* pRequestedMT)
{
- PIN_DIRECTION pindir;
- BeginEnumPins(pBF, pEP, pPin) {
- CComPtr<IPin> pFellow;
-
- if (SUCCEEDED (pPin->QueryDirection(&pindir)) &&
- pindir == direction &&
- pPin->ConnectedTo(&pFellow) == VFW_E_NOT_CONNECTED) {
- BeginEnumMediaTypes(pPin, pEM, pmt) {
- if (pmt->majortype == pRequestedMT->majortype && pmt->subtype == pRequestedMT->subtype) {
- return (pPin);
- }
- }
- EndEnumMediaTypes(pmt)
- }
- }
- EndEnumPins
- return NULL;
+ PIN_DIRECTION pindir;
+ BeginEnumPins(pBF, pEP, pPin) {
+ CComPtr<IPin> pFellow;
+
+ if (SUCCEEDED(pPin->QueryDirection(&pindir)) &&
+ pindir == direction &&
+ pPin->ConnectedTo(&pFellow) == VFW_E_NOT_CONNECTED) {
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ if (pmt->majortype == pRequestedMT->majortype && pmt->subtype == pRequestedMT->subtype) {
+ return (pPin);
+ }
+ }
+ EndEnumMediaTypes(pmt)
+ }
+ }
+ EndEnumPins
+ return NULL;
}
CStringW GetFilterName(IBaseFilter* pBF)
{
- CStringW name = _T("");
-
- if (pBF) {
- CLSID clsid = GetCLSID(pBF);
- if (clsid == CLSID_AsyncReader) {
- name = _T("File Source (Async.)");
- } else if (clsid == CLSID_URLReader) {
- name = _T("File Source (URL)");
- } else if (clsid == CLSID_WMAsfReader) {
- name = _T("WM ASF Reader");
- } else if (clsid == GUIDFromCString(_T("{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}"))) {
- name = _T("AV Source");
- } else if (clsid == GUIDFromCString(_T("{B98D13E7-55DB-4385-A33D-09FD1BA26338}"))) {
- name = _T("LAV Splitter Source");
- } else if (clsid == GUIDFromCString(_T("{55DA30FC-F16B-49FC-BAA5-AE59FC65F82D}"))) {
- name = _T("Haali Media Source");
- } else {
- CFilterInfo fi;
- if (SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
- name = fi.achName;
- }
- }
- }
-
- return name;
+ CStringW name = _T("");
+
+ if (pBF) {
+ CLSID clsid = GetCLSID(pBF);
+ if (clsid == CLSID_AsyncReader) {
+ name = _T("File Source (Async.)");
+ } else if (clsid == CLSID_URLReader) {
+ name = _T("File Source (URL)");
+ } else if (clsid == CLSID_WMAsfReader) {
+ name = _T("WM ASF Reader");
+ } else if (clsid == GUIDFromCString(_T("{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}"))) {
+ name = _T("AV Source");
+ } else if (clsid == GUIDFromCString(_T("{B98D13E7-55DB-4385-A33D-09FD1BA26338}"))) {
+ name = _T("LAV Splitter Source");
+ } else if (clsid == GUIDFromCString(_T("{55DA30FC-F16B-49FC-BAA5-AE59FC65F82D}"))) {
+ name = _T("Haali Media Source");
+ } else {
+ CFilterInfo fi;
+ if (SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ name = fi.achName;
+ }
+ }
+ }
+
+ return name;
}
CStringW GetPinName(IPin* pPin)
{
- CStringW name;
- CPinInfo pi;
- if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
- name = pi.achName;
- }
+ CStringW name;
+ CPinInfo pi;
+ if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ name = pi.achName;
+ }
- return name;
+ return name;
}
IFilterGraph* GetGraphFromFilter(IBaseFilter* pBF)
{
- if (!pBF) {
- return NULL;
- }
- IFilterGraph* pGraph = NULL;
- CFilterInfo fi;
- if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
- pGraph = fi.pGraph;
- }
- return pGraph;
+ if (!pBF) {
+ return NULL;
+ }
+ IFilterGraph* pGraph = NULL;
+ CFilterInfo fi;
+ if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ pGraph = fi.pGraph;
+ }
+ return pGraph;
}
IBaseFilter* GetFilterFromPin(IPin* pPin)
{
- if (!pPin) {
- return NULL;
- }
- IBaseFilter* pBF = NULL;
- CPinInfo pi;
- if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
- pBF = pi.pFilter;
- }
- return pBF;
+ if (!pPin) {
+ return NULL;
+ }
+ IBaseFilter* pBF = NULL;
+ CPinInfo pi;
+ if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ pBF = pi.pFilter;
+ }
+ return pBF;
}
IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
- IPin* pRet = pPin;
-
- CInterfaceList<IBaseFilter> pFilters;
-
- do {
- if (!pPin || DisplayName.IsEmpty() || !pGB) {
- break;
- }
-
- CComPtr<IPin> pPinTo;
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
- break;
- }
-
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
-
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- break;
- }
-
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- break;
- }
-
- CComPtr<IPropertyBag> pPB;
- if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
- break;
- }
-
- CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- break;
- }
-
- pFilters.AddTail(pBF);
- BeginEnumFilters(pGB, pEnum, pBF2)
- pFilters.AddTail(pBF2);
- EndEnumFilters
-
- if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
- break;
- }
-
- BeginEnumFilters(pGB, pEnum, pBF2)
- if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
- pEnum->Reset();
- }
- EndEnumFilters
-
- pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
- if (!pPinTo) {
- pGB->RemoveFilter(pBF);
- break;
- }
-
- HRESULT hr;
- if (FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL))) {
- hr = pGB->Connect(pPin, pPinTo);
- pGB->RemoveFilter(pBF);
- break;
- }
-
- BeginEnumFilters(pGB, pEnum, pBF2)
- if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
- pEnum->Reset();
- }
- EndEnumFilters
-
- pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
- if (!pRet) {
- pRet = pPin;
- pGB->RemoveFilter(pBF);
- break;
- }
- } while (false);
-
- return pRet;
+ IPin* pRet = pPin;
+
+ CInterfaceList<IBaseFilter> pFilters;
+
+ do {
+ if (!pPin || DisplayName.IsEmpty() || !pGB) {
+ break;
+ }
+
+ CComPtr<IPin> pPinTo;
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
+ break;
+ }
+
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
+
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ break;
+ }
+
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ break;
+ }
+
+ CComPtr<IPropertyBag> pPB;
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ break;
+ }
+
+ CComVariant var;
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ break;
+ }
+
+ pFilters.AddTail(pBF);
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ pFilters.AddTail(pBF2);
+ EndEnumFilters
+
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ break;
+ }
+
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
+ pEnum->Reset();
+ }
+ EndEnumFilters
+
+ pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
+ if (!pPinTo) {
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ HRESULT hr;
+ if (FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL))) {
+ hr = pGB->Connect(pPin, pPinTo);
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
+ pEnum->Reset();
+ }
+ EndEnumFilters
+
+ pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
+ if (!pRet) {
+ pRet = pPin;
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+ } while (false);
+
+ return pRet;
}
IPin* InsertFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
- do {
- if (!pPin || DisplayName.IsEmpty() || !pGB) {
- break;
- }
-
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir))) {
- break;
- }
-
- CComPtr<IPin> pFrom, pTo;
-
- if (dir == PINDIR_INPUT) {
- pPin->ConnectedTo(&pFrom);
- pTo = pPin;
- } else if (dir == PINDIR_OUTPUT) {
- pFrom = pPin;
- pPin->ConnectedTo(&pTo);
- }
-
- if (!pFrom || !pTo) {
- break;
- }
-
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
-
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- break;
- }
-
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- break;
- }
-
- CComPtr<IPropertyBag> pPB;
- if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
- break;
- }
-
- CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- break;
- }
-
- if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
- break;
- }
-
- CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
- if (!pFromTo) {
- pGB->RemoveFilter(pBF);
- break;
- }
-
- if (FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo))) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- HRESULT hr;
- if (FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL))) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- CComPtr<IPin> pToFrom = GetFirstPin(pBF, PINDIR_OUTPUT);
- if (!pToFrom) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- if (FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL))) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- pPin = pToFrom;
- } while (false);
-
- return pPin;
+ do {
+ if (!pPin || DisplayName.IsEmpty() || !pGB) {
+ break;
+ }
+
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir))) {
+ break;
+ }
+
+ CComPtr<IPin> pFrom, pTo;
+
+ if (dir == PINDIR_INPUT) {
+ pPin->ConnectedTo(&pFrom);
+ pTo = pPin;
+ } else if (dir == PINDIR_OUTPUT) {
+ pFrom = pPin;
+ pPin->ConnectedTo(&pTo);
+ }
+
+ if (!pFrom || !pTo) {
+ break;
+ }
+
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
+
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ break;
+ }
+
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ break;
+ }
+
+ CComPtr<IPropertyBag> pPB;
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ break;
+ }
+
+ CComVariant var;
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ break;
+ }
+
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ break;
+ }
+
+ CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
+ if (!pFromTo) {
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ if (FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo))) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ HRESULT hr;
+ if (FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL))) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ CComPtr<IPin> pToFrom = GetFirstPin(pBF, PINDIR_OUTPUT);
+ if (!pToFrom) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ if (FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL))) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ pPin = pToFrom;
+ } while (false);
+
+ return pPin;
}
void ExtractMediaTypes(IPin* pPin, CAtlArray<GUID>& types)
{
- types.RemoveAll();
+ types.RemoveAll();
- BeginEnumMediaTypes(pPin, pEM, pmt) {
- bool fFound = false;
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ bool fFound = false;
- for (ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2) {
- if (types[i] == pmt->majortype && types[i+1] == pmt->subtype) {
- fFound = true;
- }
- }
+ for (ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2) {
+ if (types[i] == pmt->majortype && types[i + 1] == pmt->subtype) {
+ fFound = true;
+ }
+ }
- if (!fFound) {
- types.Add(pmt->majortype);
- types.Add(pmt->subtype);
- }
- }
- EndEnumMediaTypes(pmt)
+ if (!fFound) {
+ types.Add(pmt->majortype);
+ types.Add(pmt->subtype);
+ }
+ }
+ EndEnumMediaTypes(pmt)
}
void ExtractMediaTypes(IPin* pPin, CAtlList<CMediaType>& mts)
{
- mts.RemoveAll();
+ mts.RemoveAll();
- BeginEnumMediaTypes(pPin, pEM, pmt) {
- bool fFound = false;
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ bool fFound = false;
- POSITION pos = mts.GetHeadPosition();
- while (!fFound && pos) {
- CMediaType& mt = mts.GetNext(pos);
- if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
- fFound = true;
- }
- }
+ POSITION pos = mts.GetHeadPosition();
+ while (!fFound && pos) {
+ CMediaType& mt = mts.GetNext(pos);
+ if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
+ fFound = true;
+ }
+ }
- if (!fFound) {
- mts.AddTail(CMediaType(*pmt));
- }
- }
- EndEnumMediaTypes(pmt)
+ if (!fFound) {
+ mts.AddTail(CMediaType(*pmt));
+ }
+ }
+ EndEnumMediaTypes(pmt)
}
int Eval_Exception(int n_except)
{
- if (n_except == STATUS_ACCESS_VIOLATION) {
- AfxMessageBox(_T("The property page of this filter has just caused a\nmemory access violation. The application will gently die now :)"));
- }
+ if (n_except == STATUS_ACCESS_VIOLATION) {
+ AfxMessageBox(_T("The property page of this filter has just caused a\nmemory access violation. The application will gently die now :)"));
+ }
- return EXCEPTION_CONTINUE_SEARCH;
+ return EXCEPTION_CONTINUE_SEARCH;
}
void MyOleCreatePropertyFrame(HWND hwndOwner, UINT x, UINT y, LPCOLESTR lpszCaption, ULONG cObjects, LPUNKNOWN FAR* lplpUnk, ULONG cPages, LPCLSID lpPageClsID, LCID lcid, DWORD dwReserved, LPVOID lpvReserved)
{
- __try {
- OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
- }
- __except (Eval_Exception(GetExceptionCode())) {
- // No code; this block never executed.
- }
+ __try {
+ OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
+ } __except (Eval_Exception(GetExceptionCode())) {
+ // No code; this block never executed.
+ }
}
void ShowPPage(CString DisplayName, HWND hParentWnd)
{
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker)) {
- return;
- }
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker)) {
+ return;
+ }
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- return;
- }
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ return;
+ }
- ShowPPage(pBF, hParentWnd);
+ ShowPPage(pBF, hParentWnd);
}
void ShowPPage(IUnknown* pUnk, HWND hParentWnd)
{
- CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
- if (!pSPP) {
- return;
- }
-
- CString str;
-
- CComQIPtr<IBaseFilter> pBF = pSPP;
- CFilterInfo fi;
- CComQIPtr<IPin> pPin = pSPP;
- CPinInfo pi;
- if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
- str = fi.achName;
- } else if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
- str = pi.achName;
- }
-
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if (SUCCEEDED(pSPP->GetPages(&caGUID))) {
- IUnknown* lpUnk = NULL;
- pSPP.QueryInterface(&lpUnk);
- MyOleCreatePropertyFrame(
- hParentWnd, 0, 0, CStringW(str),
- 1, (IUnknown**)&lpUnk,
- caGUID.cElems, caGUID.pElems,
- 0, 0, NULL);
- lpUnk->Release();
-
- if (caGUID.pElems) {
- CoTaskMemFree(caGUID.pElems);
- }
- }
+ CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
+ if (!pSPP) {
+ return;
+ }
+
+ CString str;
+
+ CComQIPtr<IBaseFilter> pBF = pSPP;
+ CFilterInfo fi;
+ CComQIPtr<IPin> pPin = pSPP;
+ CPinInfo pi;
+ if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ str = fi.achName;
+ } else if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ str = pi.achName;
+ }
+
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if (SUCCEEDED(pSPP->GetPages(&caGUID))) {
+ IUnknown* lpUnk = NULL;
+ pSPP.QueryInterface(&lpUnk);
+ MyOleCreatePropertyFrame(
+ hParentWnd, 0, 0, CStringW(str),
+ 1, (IUnknown**)&lpUnk,
+ caGUID.cElems, caGUID.pElems,
+ 0, 0, NULL);
+ lpUnk->Release();
+
+ if (caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ }
}
CLSID GetCLSID(IBaseFilter* pBF)
{
- CLSID clsid = GUID_NULL;
- if (pBF) {
- pBF->GetClassID(&clsid);
- }
- return clsid;
+ CLSID clsid = GUID_NULL;
+ if (pBF) {
+ pBF->GetClassID(&clsid);
+ }
+ return clsid;
}
CLSID GetCLSID(IPin* pPin)
{
- return GetCLSID(GetFilterFromPin(pPin));
+ return GetCLSID(GetFilterFromPin(pPin));
}
bool IsCLSIDRegistered(LPCTSTR clsid)
{
- CString rootkey1(_T("CLSID\\"));
- CString rootkey2(_T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\"));
+ CString rootkey1(_T("CLSID\\"));
+ CString rootkey2(_T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\"));
- return ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey1 + clsid, KEY_READ)
- || ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey2 + clsid, KEY_READ);
+ return ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey1 + clsid, KEY_READ)
+ || ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey2 + clsid, KEY_READ);
}
bool IsCLSIDRegistered(const CLSID& clsid)
{
- bool fRet = false;
+ bool fRet = false;
- LPOLESTR pStr = NULL;
- if (S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
- fRet = IsCLSIDRegistered(CString(pStr));
- CoTaskMemFree(pStr);
- }
+ LPOLESTR pStr = NULL;
+ if (S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
+ fRet = IsCLSIDRegistered(CString(pStr));
+ CoTaskMemFree(pStr);
+ }
- return fRet;
+ return fRet;
}
void CStringToBin(CString str, CAtlArray<BYTE>& data)
{
- str.Trim();
- ASSERT((str.GetLength()&1) == 0);
- data.SetCount(str.GetLength()/2);
-
- BYTE b = 0;
-
- str.MakeUpper();
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- TCHAR c = str[i];
- if (c >= _T('0') && c <= _T('9')) {
- if (!(i&1)) {
- b = ((char(c-_T('0'))<<4)&0xf0)|(b&0x0f);
- } else {
- b = (char(c-_T('0'))&0x0f)|(b&0xf0);
- }
- } else if (c >= _T('A') && c <= _T('F')) {
- if (!(i&1)) {
- b = ((char(c-_T('A')+10)<<4)&0xf0)|(b&0x0f);
- } else {
- b = (char(c-_T('A')+10)&0x0f)|(b&0xf0);
- }
- } else {
- break;
- }
-
- if (i&1) {
- data[i>>1] = b;
- b = 0;
- }
- }
+ str.Trim();
+ ASSERT((str.GetLength() & 1) == 0);
+ data.SetCount(str.GetLength() / 2);
+
+ BYTE b = 0;
+
+ str.MakeUpper();
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ TCHAR c = str[i];
+ if (c >= _T('0') && c <= _T('9')) {
+ if (!(i & 1)) {
+ b = ((char(c - _T('0')) << 4) & 0xf0) | (b & 0x0f);
+ } else {
+ b = (char(c - _T('0')) & 0x0f) | (b & 0xf0);
+ }
+ } else if (c >= _T('A') && c <= _T('F')) {
+ if (!(i & 1)) {
+ b = ((char(c - _T('A') + 10) << 4) & 0xf0) | (b & 0x0f);
+ } else {
+ b = (char(c - _T('A') + 10) & 0x0f) | (b & 0xf0);
+ }
+ } else {
+ break;
+ }
+
+ if (i & 1) {
+ data[i >> 1] = b;
+ b = 0;
+ }
+ }
}
CString BinToCString(const BYTE* ptr, size_t len)
{
- CString ret;
- TCHAR high, low;
+ CString ret;
+ TCHAR high, low;
- while (len-- > 0) {
- high = (*ptr>>4) >= 10 ? (*ptr>>4)-10 + _T('A') : (*ptr>>4) + _T('0');
- low = (*ptr&0xf) >= 10 ? (*ptr&0xf)-10 + _T('A') : (*ptr&0xf) + _T('0');
+ while (len-- > 0) {
+ high = (*ptr >> 4) >= 10 ? (*ptr >> 4) - 10 + _T('A') : (*ptr >> 4) + _T('0');
+ low = (*ptr & 0xf) >= 10 ? (*ptr & 0xf) - 10 + _T('A') : (*ptr & 0xf) + _T('0');
- ret.AppendFormat(_T("%c%c"), high, low);
+ ret.AppendFormat(_T("%c%c"), high, low);
- ptr++;
- }
+ ptr++;
+ }
- return ret;
+ return ret;
}
static void FindFiles(CString fn, CAtlList<CString>& files)
{
- CString path = fn;
- path.Replace('/', '\\');
- path = path.Left(path.ReverseFind('\\')+1);
+ CString path = fn;
+ path.Replace('/', '\\');
+ path = path.Left(path.ReverseFind('\\') + 1);
- WIN32_FIND_DATA findData;
- HANDLE h = FindFirstFile(fn, &findData);
- if (h != INVALID_HANDLE_VALUE) {
- do {
- files.AddTail(path + findData.cFileName);
- } while (FindNextFile(h, &findData));
+ WIN32_FIND_DATA findData;
+ HANDLE h = FindFirstFile(fn, &findData);
+ if (h != INVALID_HANDLE_VALUE) {
+ do {
+ files.AddTail(path + findData.cFileName);
+ } while (FindNextFile(h, &findData));
- FindClose(h);
- }
+ FindClose(h);
+ }
}
cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files)
{
- files.RemoveAll();
-
- CString path;
- path.Format(_T("%c:"), drive);
-
- if (GetDriveType(path + _T("\\")) == DRIVE_CDROM) {
- // CDROM_VideoCD
- FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
- FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
- FindFiles(path + _T("\\mpeg2\\avseq??.dat"), files);
- FindFiles(path + _T("\\mpeg2\\avseq??.mpg"), files);
- FindFiles(path + _T("\\mpegav\\music??.dat"), files);
- FindFiles(path + _T("\\mpegav\\music??.mpg"), files);
- FindFiles(path + _T("\\mpeg2\\music??.dat"), files);
- FindFiles(path + _T("\\mpeg2\\music??.mpg"), files);
- if (files.GetCount() > 0) {
- return CDROM_VideoCD;
- }
-
- // CDROM_DVDVideo
- FindFiles(path + _T("\\VIDEO_TS\\video_ts.ifo"), files);
- if (files.GetCount() > 0) {
- return CDROM_DVDVideo;
- }
-
- // CDROM_Audio
- HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
- if (hDrive != INVALID_HANDLE_VALUE) {
- DWORD BytesReturned;
- CDROM_TOC TOC;
- if (DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0)) {
- for (ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++) {
- // MMC-3 Draft Revision 10g: Table 222 - Q Sub-channel control field
- TOC.TrackData[i-1].Control &= 5;
- if (TOC.TrackData[i-1].Control == 0 || TOC.TrackData[i-1].Control == 1) {
- CString fn;
- fn.Format(_T("%s\\track%02d.cda"), path, i);
- files.AddTail(fn);
- }
- }
- }
-
- CloseHandle(hDrive);
- }
- if (files.GetCount() > 0) {
- return CDROM_Audio;
- }
-
- // it is a cdrom but nothing special
- return CDROM_Unknown;
- }
-
- return CDROM_NotFound;
+ files.RemoveAll();
+
+ CString path;
+ path.Format(_T("%c:"), drive);
+
+ if (GetDriveType(path + _T("\\")) == DRIVE_CDROM) {
+ // CDROM_VideoCD
+ FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
+ FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
+ FindFiles(path + _T("\\mpeg2\\avseq??.dat"), files);
+ FindFiles(path + _T("\\mpeg2\\avseq??.mpg"), files);
+ FindFiles(path + _T("\\mpegav\\music??.dat"), files);
+ FindFiles(path + _T("\\mpegav\\music??.mpg"), files);
+ FindFiles(path + _T("\\mpeg2\\music??.dat"), files);
+ FindFiles(path + _T("\\mpeg2\\music??.mpg"), files);
+ if (files.GetCount() > 0) {
+ return CDROM_VideoCD;
+ }
+
+ // CDROM_DVDVideo
+ FindFiles(path + _T("\\VIDEO_TS\\video_ts.ifo"), files);
+ if (files.GetCount() > 0) {
+ return CDROM_DVDVideo;
+ }
+
+ // CDROM_Audio
+ HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
+ if (hDrive != INVALID_HANDLE_VALUE) {
+ DWORD BytesReturned;
+ CDROM_TOC TOC;
+ if (DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0)) {
+ for (ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++) {
+ // MMC-3 Draft Revision 10g: Table 222 - Q Sub-channel control field
+ TOC.TrackData[i - 1].Control &= 5;
+ if (TOC.TrackData[i - 1].Control == 0 || TOC.TrackData[i - 1].Control == 1) {
+ CString fn;
+ fn.Format(_T("%s\\track%02d.cda"), path, i);
+ files.AddTail(fn);
+ }
+ }
+ }
+
+ CloseHandle(hDrive);
+ }
+ if (files.GetCount() > 0) {
+ return CDROM_Audio;
+ }
+
+ // it is a cdrom but nothing special
+ return CDROM_Unknown;
+ }
+
+ return CDROM_NotFound;
}
CString GetDriveLabel(TCHAR drive)
{
- CString label;
+ CString label;
- CString path;
- path.Format(_T("%c:\\"), drive);
- TCHAR VolumeNameBuffer[_MAX_PATH], FileSystemNameBuffer[_MAX_PATH];
- DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
- if (GetVolumeInformation(path,
- VolumeNameBuffer, _MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
- &FileSystemFlags, FileSystemNameBuffer, _MAX_PATH)) {
- label = VolumeNameBuffer;
- }
+ CString path;
+ path.Format(_T("%c:\\"), drive);
+ TCHAR VolumeNameBuffer[_MAX_PATH], FileSystemNameBuffer[_MAX_PATH];
+ DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
+ if (GetVolumeInformation(path,
+ VolumeNameBuffer, _MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
+ &FileSystemFlags, FileSystemNameBuffer, _MAX_PATH)) {
+ label = VolumeNameBuffer;
+ }
- return label;
+ return label;
}
bool GetKeyFrames(CString fn, CUIntArray& kfs)
{
- kfs.RemoveAll();
+ kfs.RemoveAll();
- CString fn2 = CString(fn).MakeLower();
- if (fn2.Mid(fn2.ReverseFind('.')+1) == _T("avi")) {
- AVIFileInit();
+ CString fn2 = CString(fn).MakeLower();
+ if (fn2.Mid(fn2.ReverseFind('.') + 1) == _T("avi")) {
+ AVIFileInit();
- PAVIFILE pfile;
- if (AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0) {
- AVIFILEINFO afi;
- memset(&afi, 0, sizeof(afi));
- AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));
+ PAVIFILE pfile;
+ if (AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0) {
+ AVIFILEINFO afi;
+ memset(&afi, 0, sizeof(afi));
+ AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));
- CComPtr<IAVIStream> pavi;
- if (AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK) {
- AVISTREAMINFO si;
- AVIStreamInfo(pavi, &si, sizeof(si));
+ CComPtr<IAVIStream> pavi;
+ if (AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK) {
+ AVISTREAMINFO si;
+ AVIStreamInfo(pavi, &si, sizeof(si));
- if (afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES) {
- kfs.SetSize(si.dwLength);
- for (DWORD kf = 0; kf < si.dwLength; kf++) {
- kfs[kf] = kf;
- }
- } else {
- for (LONG kf = 0; ; kf++) {
- kf = pavi->FindSample(kf, FIND_KEY|FIND_NEXT);
- if (kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) {
- break;
- }
- kfs.Add(kf);
- }
+ if (afi.dwCaps & AVIFILECAPS_ALLKEYFRAMES) {
+ kfs.SetSize(si.dwLength);
+ for (DWORD kf = 0; kf < si.dwLength; kf++) {
+ kfs[kf] = kf;
+ }
+ } else {
+ for (LONG kf = 0; ; kf++) {
+ kf = pavi->FindSample(kf, FIND_KEY | FIND_NEXT);
+ if (kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount() - 1] >= (UINT)kf) {
+ break;
+ }
+ kfs.Add(kf);
+ }
- if (kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] < si.dwLength-1) {
- kfs.Add(si.dwLength-1);
- }
- }
- }
+ if (kfs.GetCount() > 0 && kfs[kfs.GetCount() - 1] < si.dwLength - 1) {
+ kfs.Add(si.dwLength - 1);
+ }
+ }
+ }
- AVIFileRelease(pfile);
- }
+ AVIFileRelease(pfile);
+ }
- AVIFileExit();
- }
+ AVIFileExit();
+ }
- return (kfs.GetCount() > 0);
+ return (kfs.GetCount() > 0);
}
DVD_HMSF_TIMECODE RT2HMSF(REFERENCE_TIME rt, double fps) // use to remember the current position
{
- DVD_HMSF_TIMECODE hmsf = {
- (BYTE)((rt/10000000/60/60)),
- (BYTE)((rt/10000000/60)%60),
- (BYTE)((rt/10000000)%60),
- (BYTE)(1.0*((rt/10000)%1000) * fps / 1000)
- };
+ DVD_HMSF_TIMECODE hmsf = {
+ (BYTE)((rt / 10000000 / 60 / 60)),
+ (BYTE)((rt / 10000000 / 60) % 60),
+ (BYTE)((rt / 10000000) % 60),
+ (BYTE)(1.0 * ((rt / 10000) % 1000) * fps / 1000)
+ };
- return hmsf;
+ return hmsf;
}
DVD_HMSF_TIMECODE RT2HMS_r(REFERENCE_TIME rt) // use only for information (for display on the screen)
{
- rt = (rt + 5000000) / 10000000;
- DVD_HMSF_TIMECODE hmsf = {
- (BYTE)(rt / 3600),
- (BYTE)(rt / 60 % 60),
- (BYTE)(rt % 60),
- 0
- };
+ rt = (rt + 5000000) / 10000000;
+ DVD_HMSF_TIMECODE hmsf = {
+ (BYTE)(rt / 3600),
+ (BYTE)(rt / 60 % 60),
+ (BYTE)(rt % 60),
+ 0
+ };
- return hmsf;
+ return hmsf;
}
REFERENCE_TIME HMSF2RT(DVD_HMSF_TIMECODE hmsf, double fps)
{
- if (fps == 0) {
- hmsf.bFrames = 0;
- fps = 1;
- }
- return (REFERENCE_TIME)((((REFERENCE_TIME)hmsf.bHours*60+hmsf.bMinutes)*60+hmsf.bSeconds)*1000+1.0*hmsf.bFrames*1000/fps)*10000;
+ if (fps == 0) {
+ hmsf.bFrames = 0;
+ fps = 1;
+ }
+ return (REFERENCE_TIME)((((REFERENCE_TIME)hmsf.bHours * 60 + hmsf.bMinutes) * 60 + hmsf.bSeconds) * 1000 + 1.0 * hmsf.bFrames * 1000 / fps) * 10000;
}
void memsetd(void* dst, unsigned int c, size_t nbytes)
{
#ifndef _WIN64
- if (!(g_cpuid.m_flags & g_cpuid.sse2)) {
- __asm {
- mov eax, c
- mov ecx, nbytes
- shr ecx, 2
- mov edi, dst
- cld
- rep stosd
- }
- return;
- }
+ if (!(g_cpuid.m_flags & g_cpuid.sse2)) {
+ __asm {
+ mov eax, c
+ mov ecx, nbytes
+ shr ecx, 2
+ mov edi, dst
+ cld
+ rep stosd
+ }
+ return;
+ }
#endif
- size_t n = nbytes / 4;
- size_t o = n - (n % 4);
-
- __m128i val = _mm_set1_epi32 ( (int)c );
- if (((uintptr_t)dst & 0x0F) == 0) { // 16-byte aligned
- for (size_t i = 0; i < o; i+=4) {
- _mm_store_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
- }
- } else {
- for (size_t i = 0; i < o; i+=4) {
- _mm_storeu_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
- }
- }
-
- switch (n - o) {
- case 3:
- ((DWORD*)dst)[o + 2] = c;
- case 2:
- ((DWORD*)dst)[o + 1] = c;
- case 1:
- ((DWORD*)dst)[o + 0] = c;
- }
+ size_t n = nbytes / 4;
+ size_t o = n - (n % 4);
+
+ __m128i val = _mm_set1_epi32((int)c);
+ if (((uintptr_t)dst & 0x0F) == 0) { // 16-byte aligned
+ for (size_t i = 0; i < o; i += 4) {
+ _mm_store_si128((__m128i*) & (((DWORD*)dst)[i]), val);
+ }
+ } else {
+ for (size_t i = 0; i < o; i += 4) {
+ _mm_storeu_si128((__m128i*) & (((DWORD*)dst)[i]), val);
+ }
+ }
+
+ switch (n - o) {
+ case 3:
+ ((DWORD*)dst)[o + 2] = c;
+ case 2:
+ ((DWORD*)dst)[o + 1] = c;
+ case 1:
+ ((DWORD*)dst)[o + 0] = c;
+ }
}
void memsetw(void* dst, unsigned short c, size_t nbytes)
{
- memsetd(dst, c << 16 | c, nbytes);
+ memsetd(dst, c << 16 | c, nbytes);
- size_t n = nbytes / 2;
- size_t o = (n / 2) * 2;
- if ((n - o) == 1) {
- ((WORD*)dst)[o] = c;
- }
+ size_t n = nbytes / 2;
+ size_t o = (n / 2) * 2;
+ if ((n - o) == 1) {
+ ((WORD*)dst)[o] = c;
+ }
}
bool ExtractBIH(const AM_MEDIA_TYPE* pmt, BITMAPINFOHEADER* bih)
{
- if (pmt && bih) {
- memset(bih, 0, sizeof(*bih));
-
- if (pmt->formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_MPEGVideo) {
- VIDEOINFOHEADER* vih = &((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
- VIDEOINFOHEADER2* vih = &((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_DiracVideoInfo) {
- VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- }
- }
-
- return false;
+ if (pmt && bih) {
+ memset(bih, 0, sizeof(*bih));
+
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
+ VIDEOINFOHEADER* vih = &((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
+ VIDEOINFOHEADER2* vih = &((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_DiracVideoInfo) {
+ VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ }
+ }
+
+ return false;
}
bool ExtractAvgTimePerFrame(const AM_MEDIA_TYPE* pmt, REFERENCE_TIME& rtAvgTimePerFrame)
{
- if (pmt->formattype==FORMAT_VideoInfo) {
- rtAvgTimePerFrame = ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame;
- } else if (pmt->formattype==FORMAT_VideoInfo2) {
- rtAvgTimePerFrame = ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame;
- } else if (pmt->formattype==FORMAT_MPEGVideo) {
- rtAvgTimePerFrame = ((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- } else if (pmt->formattype==FORMAT_MPEG2Video) {
- rtAvgTimePerFrame = ((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- } else {
- return false;
- }
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ rtAvgTimePerFrame = ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ rtAvgTimePerFrame = ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame;
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
+ rtAvgTimePerFrame = ((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
+ } else if (pmt->formattype == FORMAT_MPEG2Video) {
+ rtAvgTimePerFrame = ((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
+ } else {
+ return false;
+ }
- return true;
+ return true;
}
bool ExtractBIH(IMediaSample* pMS, BITMAPINFOHEADER* bih)
{
- AM_MEDIA_TYPE* pmt = NULL;
- pMS->GetMediaType(&pmt);
- if (pmt) {
- bool fRet = ExtractBIH(pmt, bih);
- DeleteMediaType(pmt);
- return fRet;
- }
+ AM_MEDIA_TYPE* pmt = NULL;
+ pMS->GetMediaType(&pmt);
+ if (pmt) {
+ bool fRet = ExtractBIH(pmt, bih);
+ DeleteMediaType(pmt);
+ return fRet;
+ }
- return false;
+ return false;
}
bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary)
{
- w = h = arx = ary = 0;
-
- if (pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- w = vih->bmiHeader.biWidth;
- h = abs(vih->bmiHeader.biHeight);
- arx = w * vih->bmiHeader.biYPelsPerMeter;
- ary = h * vih->bmiHeader.biXPelsPerMeter;
- } else if (pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- w = vih->bmiHeader.biWidth;
- h = abs(vih->bmiHeader.biHeight);
- arx = vih->dwPictAspectRatioX;
- ary = vih->dwPictAspectRatioY;
- } else {
- return false;
- }
-
- if (!arx || !ary) {
- BYTE* ptr = NULL;
- DWORD len = 0;
-
- if (pmt->formattype == FORMAT_MPEGVideo) {
- ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
- len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
-
- if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
- w = (ptr[4]<<4)|(ptr[5]>>4);
- h = ((ptr[5]&0xf)<<8)|ptr[6];
- float ar[] = {
- 1.0000f,1.0000f,0.6735f,0.7031f,
- 0.7615f,0.8055f,0.8437f,0.8935f,
- 0.9157f,0.9815f,1.0255f,1.0695f,
- 1.0950f,1.1575f,1.2015f,1.0000f,
- };
- arx = (int)((float)w / ar[ptr[7]>>4] + 0.5);
- ary = h;
- }
- } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
- ptr = (BYTE*)((MPEG2VIDEOINFO*)pmt->pbFormat)->dwSequenceHeader;
- len = ((MPEG2VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
-
- if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
- w = (ptr[4]<<4)|(ptr[5]>>4);
- h = ((ptr[5]&0xf)<<8)|ptr[6];
- struct {
- int x, y;
- } ar[] = {{w,h},{4,3},{16,9},{221,100},{w,h}};
- int i = min(max(ptr[7]>>4, 1), 5)-1;
- arx = ar[i].x;
- ary = ar[i].y;
- }
- }
- }
-
- if (!arx || !ary) {
- arx = w;
- ary = h;
- }
-
- DWORD a = arx, b = ary;
- while (a) {
- int tmp = a;
- a = b % tmp;
- b = tmp;
- }
- if (b) {
- arx /= b, ary /= b;
- }
-
- return true;
+ w = h = arx = ary = 0;
+
+ if (pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ w = vih->bmiHeader.biWidth;
+ h = abs(vih->bmiHeader.biHeight);
+ arx = w * vih->bmiHeader.biYPelsPerMeter;
+ ary = h * vih->bmiHeader.biXPelsPerMeter;
+ } else if (pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ w = vih->bmiHeader.biWidth;
+ h = abs(vih->bmiHeader.biHeight);
+ arx = vih->dwPictAspectRatioX;
+ ary = vih->dwPictAspectRatioY;
+ } else {
+ return false;
+ }
+
+ if (!arx || !ary) {
+ BYTE* ptr = NULL;
+ DWORD len = 0;
+
+ if (pmt->formattype == FORMAT_MPEGVideo) {
+ ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
+ len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
+
+ if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
+ w = (ptr[4] << 4) | (ptr[5] >> 4);
+ h = ((ptr[5] & 0xf) << 8) | ptr[6];
+ float ar[] = {
+ 1.0000f, 1.0000f, 0.6735f, 0.7031f,
+ 0.7615f, 0.8055f, 0.8437f, 0.8935f,
+ 0.9157f, 0.9815f, 1.0255f, 1.0695f,
+ 1.0950f, 1.1575f, 1.2015f, 1.0000f,
+ };
+ arx = (int)((float)w / ar[ptr[7] >> 4] + 0.5);
+ ary = h;
+ }
+ } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
+ ptr = (BYTE*)((MPEG2VIDEOINFO*)pmt->pbFormat)->dwSequenceHeader;
+ len = ((MPEG2VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
+
+ if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
+ w = (ptr[4] << 4) | (ptr[5] >> 4);
+ h = ((ptr[5] & 0xf) << 8) | ptr[6];
+ struct {
+ int x, y;
+ } ar[] = {{w, h}, {4, 3}, {16, 9}, {221, 100}, {w, h}};
+ int i = min(max(ptr[7] >> 4, 1), 5) - 1;
+ arx = ar[i].x;
+ ary = ar[i].y;
+ }
+ }
+ }
+
+ if (!arx || !ary) {
+ arx = w;
+ ary = h;
+ }
+
+ DWORD a = arx, b = ary;
+ while (a) {
+ int tmp = a;
+ a = b % tmp;
+ b = tmp;
+ }
+ if (b) {
+ arx /= b, ary /= b;
+ }
+
+ return true;
}
bool MakeMPEG2MediaType(CMediaType& mt, BYTE* seqhdr, DWORD len, int w, int h)
{
- if (len < 4 || *(DWORD*)seqhdr != 0xb3010000) {
- mt = CMediaType();
+ if (len < 4 || *(DWORD*)seqhdr != 0xb3010000) {
+ mt = CMediaType();
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- mt.formattype = FORMAT_MPEG2Video;
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader));
- memset(mt.Format(), 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = w;
- vih->hdr.bmiHeader.biHeight = h;
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader));
+ memset(mt.Format(), 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = w;
+ vih->hdr.bmiHeader.biHeight = h;
- vih->cbSequenceHeader = 0;
+ vih->cbSequenceHeader = 0;
- return true;
- }
+ return true;
+ }
- BYTE* seqhdr_ext = NULL;
+ BYTE* seqhdr_ext = NULL;
- BYTE* seqhdr_end = seqhdr + 7;
+ BYTE* seqhdr_end = seqhdr + 7;
- while (seqhdr_end < (seqhdr + len - 6)) {
- if (*(DWORD*)seqhdr_end == 0xb5010000) {
- seqhdr_ext = seqhdr_end;
- seqhdr_end += 10;
- len = (DWORD)(seqhdr_end - seqhdr);
- break;
- }
- seqhdr_end++;
- }
+ while (seqhdr_end < (seqhdr + len - 6)) {
+ if (*(DWORD*)seqhdr_end == 0xb5010000) {
+ seqhdr_ext = seqhdr_end;
+ seqhdr_end += 10;
+ len = (DWORD)(seqhdr_end - seqhdr);
+ break;
+ }
+ seqhdr_end++;
+ }
- mt = CMediaType();
+ mt = CMediaType();
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- mt.formattype = FORMAT_MPEG2Video;
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + len);
- memset(mt.Format(), 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = w;
- vih->hdr.bmiHeader.biHeight = h;
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + len);
+ memset(mt.Format(), 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = w;
+ vih->hdr.bmiHeader.biHeight = h;
- BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
- memcpy(pSequenceHeader, seqhdr, len);
- vih->cbSequenceHeader = len;
+ BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
+ memcpy(pSequenceHeader, seqhdr, len);
+ vih->cbSequenceHeader = len;
- static char profile[8] = {
- 0, AM_MPEG2Profile_High, AM_MPEG2Profile_SpatiallyScalable, AM_MPEG2Profile_SNRScalable,
- AM_MPEG2Profile_Main, AM_MPEG2Profile_Simple, 0, 0
- };
+ static char profile[8] = {
+ 0, AM_MPEG2Profile_High, AM_MPEG2Profile_SpatiallyScalable, AM_MPEG2Profile_SNRScalable,
+ AM_MPEG2Profile_Main, AM_MPEG2Profile_Simple, 0, 0
+ };
- static char level[16] = {
- 0, 0, 0, 0,
- AM_MPEG2Level_High, 0, AM_MPEG2Level_High1440, 0,
- AM_MPEG2Level_Main, 0, AM_MPEG2Level_Low, 0,
- 0, 0, 0, 0
- };
+ static char level[16] = {
+ 0, 0, 0, 0,
+ AM_MPEG2Level_High, 0, AM_MPEG2Level_High1440, 0,
+ AM_MPEG2Level_Main, 0, AM_MPEG2Level_Low, 0,
+ 0, 0, 0, 0
+ };
- if (seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10) {
- vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
- vih->dwLevel = level[seqhdr_ext[5] >> 4];
- }
+ if (seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10) {
+ vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
+ vih->dwLevel = level[seqhdr_ext[5] >> 4];
+ }
- return true;
+ return true;
}
unsigned __int64 GetFileVersion(LPCTSTR fn)
{
- unsigned __int64 ret = 0;
+ unsigned __int64 ret = 0;
- DWORD buff[4];
- VS_FIXEDFILEINFO* pvsf = (VS_FIXEDFILEINFO*)buff;
- DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
- DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
+ DWORD buff[4];
+ VS_FIXEDFILEINFO* pvsf = (VS_FIXEDFILEINFO*)buff;
+ DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
+ DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
- if (len) {
- TCHAR* b1 = DNew TCHAR[len];
- if (b1) {
- UINT uLen;
- if (GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen)) {
- ret = ((unsigned __int64)pvsf->dwFileVersionMS<<32) | pvsf->dwFileVersionLS;
- }
+ if (len) {
+ TCHAR* b1 = DNew TCHAR[len];
+ if (b1) {
+ UINT uLen;
+ if (GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen)) {
+ ret = ((unsigned __int64)pvsf->dwFileVersionMS << 32) | pvsf->dwFileVersionLS;
+ }
- delete [] b1;
- }
- }
+ delete [] b1;
+ }
+ }
- return ret;
+ return ret;
}
bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyName)
{
- if (!ppBF) {
- return false;
- }
+ if (!ppBF) {
+ return false;
+ }
- *ppBF = NULL;
- FriendlyName.Empty();
+ *ppBF = NULL;
+ FriendlyName.Empty();
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- return false;
- }
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ return false;
+ }
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF) {
- return false;
- }
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF) {
+ return false;
+ }
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- FriendlyName = var.bstrVal;
- }
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ FriendlyName = var.bstrVal;
+ }
- return true;
+ return true;
}
IBaseFilter* AppendFilter(IPin* pPin, IMoniker* pMoniker, IGraphBuilder* pGB)
{
- do {
- if (!pPin || !pMoniker || !pGB) {
- break;
- }
+ do {
+ if (!pPin || !pMoniker || !pGB) {
+ break;
+ }
- CComPtr<IPin> pPinTo;
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
- break;
- }
+ CComPtr<IPin> pPinTo;
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
+ break;
+ }
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IPropertyBag> pPB;
- if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
- break;
- }
+ CComPtr<IPropertyBag> pPB;
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ break;
+ }
- CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- break;
- }
+ CComVariant var;
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ break;
+ }
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- break;
- }
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ break;
+ }
- if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
- break;
- }
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ break;
+ }
- BeginEnumPins(pBF, pEP, pPinTo) {
- PIN_DIRECTION dir;
- if (FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT) {
- continue;
- }
+ BeginEnumPins(pBF, pEP, pPinTo) {
+ PIN_DIRECTION dir;
+ if (FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT) {
+ continue;
+ }
- if (SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL))) {
- return pBF;
- }
- }
- EndEnumFilters
+ if (SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL))) {
+ return pBF;
+ }
+ }
+ EndEnumFilters
- pGB->RemoveFilter(pBF);
- } while (false);
+ pGB->RemoveFilter(pBF);
+ } while (false);
- return NULL;
+ return NULL;
}
CStringW GetFriendlyName(CStringW DisplayName)
{
- CStringW FriendlyName;
+ CStringW FriendlyName;
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- return false;
- }
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ return false;
+ }
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- FriendlyName = var.bstrVal;
- }
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ FriendlyName = var.bstrVal;
+ }
- return FriendlyName;
+ return FriendlyName;
}
typedef struct {
- CString path;
- HINSTANCE hInst;
- CLSID clsid;
+ CString path;
+ HINSTANCE hInst;
+ CLSID clsid;
} ExternalObject;
static CAtlList<ExternalObject> s_extobjs;
HRESULT LoadExternalObject(LPCTSTR path, REFCLSID clsid, REFIID iid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- CString fullpath = MakeFullPath(path);
+ CString fullpath = MakeFullPath(path);
- HINSTANCE hInst = NULL;
- bool fFound = false;
+ HINSTANCE hInst = NULL;
+ bool fFound = false;
- POSITION pos = s_extobjs.GetHeadPosition();
- while (pos) {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- if (!eo.path.CompareNoCase(fullpath)) {
- hInst = eo.hInst;
- fFound = true;
- break;
- }
- }
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while (pos) {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ if (!eo.path.CompareNoCase(fullpath)) {
+ hInst = eo.hInst;
+ fFound = true;
+ break;
+ }
+ }
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if (!hInst) {
- hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE);
- }
- if (hInst) {
- typedef HRESULT (__stdcall * PDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
- PDllGetClassObject p = (PDllGetClassObject)GetProcAddress(hInst, "DllGetClassObject");
+ if (!hInst) {
+ hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE);
+ }
+ if (hInst) {
+ typedef HRESULT(__stdcall * PDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
+ PDllGetClassObject p = (PDllGetClassObject)GetProcAddress(hInst, "DllGetClassObject");
- if (p && FAILED(hr = p(clsid, iid, ppv))) {
- CComPtr<IClassFactory> pCF;
- if (SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF))) {
- hr = pCF->CreateInstance(NULL, iid, ppv);
- }
- }
- }
+ if (p && FAILED(hr = p(clsid, iid, ppv))) {
+ CComPtr<IClassFactory> pCF;
+ if (SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF))) {
+ hr = pCF->CreateInstance(NULL, iid, ppv);
+ }
+ }
+ }
- if (FAILED(hr) && hInst && !fFound) {
- CoFreeLibrary(hInst);
- return hr;
- }
+ if (FAILED(hr) && hInst && !fFound) {
+ CoFreeLibrary(hInst);
+ return hr;
+ }
- if (hInst && !fFound) {
- ExternalObject eo;
- eo.path = fullpath;
- eo.hInst = hInst;
- eo.clsid = clsid;
- s_extobjs.AddTail(eo);
- }
+ if (hInst && !fFound) {
+ ExternalObject eo;
+ eo.path = fullpath;
+ eo.hInst = hInst;
+ eo.clsid = clsid;
+ s_extobjs.AddTail(eo);
+ }
- return hr;
+ return hr;
}
HRESULT LoadExternalFilter(LPCTSTR path, REFCLSID clsid, IBaseFilter** ppBF)
{
- return LoadExternalObject(path, clsid, __uuidof(IBaseFilter), (void**)ppBF);
+ return LoadExternalObject(path, clsid, __uuidof(IBaseFilter), (void**)ppBF);
}
HRESULT LoadExternalPropertyPage(IPersist* pP, REFCLSID clsid, IPropertyPage** ppPP)
{
- CLSID clsid2 = GUID_NULL;
- if (FAILED(pP->GetClassID(&clsid2))) {
- return E_FAIL;
- }
+ CLSID clsid2 = GUID_NULL;
+ if (FAILED(pP->GetClassID(&clsid2))) {
+ return E_FAIL;
+ }
- POSITION pos = s_extobjs.GetHeadPosition();
- while (pos) {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- if (eo.clsid == clsid2) {
- return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
- }
- }
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while (pos) {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ if (eo.clsid == clsid2) {
+ return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
+ }
+ }
- return E_FAIL;
+ return E_FAIL;
}
void UnloadExternalObjects()
{
- POSITION pos = s_extobjs.GetHeadPosition();
- while (pos) {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- CoFreeLibrary(eo.hInst);
- }
- s_extobjs.RemoveAll();
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while (pos) {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ CoFreeLibrary(eo.hInst);
+ }
+ s_extobjs.RemoveAll();
}
CString MakeFullPath(LPCTSTR path)
{
- CString full(path);
- full.Replace('/', '\\');
+ CString full(path);
+ full.Replace('/', '\\');
- CString fn;
- fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(_MAX_PATH), _MAX_PATH));
- CPath p(fn);
+ CString fn;
+ fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(_MAX_PATH), _MAX_PATH));
+ CPath p(fn);
- if (full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\') {
- p.StripToRoot();
- full = CString(p) + full.Mid(1);
- } else if (full.Find(_T(":\\")) < 0) {
- p.RemoveFileSpec();
- p.AddBackslash();
- full = CString(p) + full;
- }
+ if (full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\') {
+ p.StripToRoot();
+ full = CString(p) + full.Mid(1);
+ } else if (full.Find(_T(":\\")) < 0) {
+ p.RemoveFileSpec();
+ p.AddBackslash();
+ full = CString(p) + full;
+ }
- CPath c(full);
- c.Canonicalize();
- return CString(c);
+ CPath c(full);
+ c.Canonicalize();
+ return CString(c);
}
//
CString GetMediaTypeName(const GUID& guid)
{
- CString ret = guid == GUID_NULL
- ? _T("Any type")
- : CString(GuidNames[guid]);
+ CString ret = guid == GUID_NULL
+ ? _T("Any type")
+ : CString(GuidNames[guid]);
- if (ret == _T("FOURCC GUID")) {
- CString str;
- if (guid.Data1 >= 0x10000) {
- str.Format(_T("Video: %c%c%c%c"), (guid.Data1>>0)&0xff, (guid.Data1>>8)&0xff, (guid.Data1>>16)&0xff, (guid.Data1>>24)&0xff);
- } else {
- str.Format(_T("Audio: 0x%08x"), guid.Data1);
- }
- ret = str;
- } else if (ret == _T("Unknown GUID Name")) {
- WCHAR null[128] = {0}, buff[128];
- StringFromGUID2(GUID_NULL, null, 127);
- ret = CString(CStringW(StringFromGUID2(guid, buff, 127) ? buff : null));
- }
+ if (ret == _T("FOURCC GUID")) {
+ CString str;
+ if (guid.Data1 >= 0x10000) {
+ str.Format(_T("Video: %c%c%c%c"), (guid.Data1 >> 0) & 0xff, (guid.Data1 >> 8) & 0xff, (guid.Data1 >> 16) & 0xff, (guid.Data1 >> 24) & 0xff);
+ } else {
+ str.Format(_T("Audio: 0x%08x"), guid.Data1);
+ }
+ ret = str;
+ } else if (ret == _T("Unknown GUID Name")) {
+ WCHAR null[128] = {0}, buff[128];
+ StringFromGUID2(GUID_NULL, null, 127);
+ ret = CString(CStringW(StringFromGUID2(guid, buff, 127) ? buff : null));
+ }
- return ret;
+ return ret;
}
GUID GUIDFromCString(CString str)
{
- GUID guid = GUID_NULL;
- HRESULT hr = CLSIDFromString(CComBSTR(str), &guid);
- ASSERT(SUCCEEDED(hr));
- UNREFERENCED_PARAMETER(hr);
- return guid;
+ GUID guid = GUID_NULL;
+ HRESULT hr = CLSIDFromString(CComBSTR(str), &guid);
+ ASSERT(SUCCEEDED(hr));
+ UNREFERENCED_PARAMETER(hr);
+ return guid;
}
HRESULT GUIDFromCString(CString str, GUID& guid)
{
- guid = GUID_NULL;
- return CLSIDFromString(CComBSTR(str), &guid);
+ guid = GUID_NULL;
+ return CLSIDFromString(CComBSTR(str), &guid);
}
CString CStringFromGUID(const GUID& guid)
{
- WCHAR null[128] = {0}, buff[128];
- StringFromGUID2(GUID_NULL, null, 127);
- return CString(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);
+ WCHAR null[128] = {0}, buff[128];
+ StringFromGUID2(GUID_NULL, null, 127);
+ return CString(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);
}
CStringW UTF8To16(LPCSTR utf8)
{
- CStringW str;
- int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0)-1;
- if (n < 0) {
- return str;
- }
- str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n+1)-1);
- return str;
+ CStringW str;
+ int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0) - 1;
+ if (n < 0) {
+ return str;
+ }
+ str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n + 1) - 1);
+ return str;
}
CStringA UTF16To8(LPCWSTR utf16)
{
- CStringA str;
- int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL)-1;
- if (n < 0) {
- return str;
- }
- str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n+1, NULL, NULL)-1);
- return str;
+ CStringA str;
+ int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL) - 1;
+ if (n < 0) {
+ return str;
+ }
+ str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n + 1, NULL, NULL) - 1);
+ return str;
}
CStringW UTF8ToStringW(const char* S)
{
- CStringW str;
- if (S==NULL) {
- return str;
- }
-
- // Don't use MultiByteToWideChar(), some characters are not well decoded
- const unsigned char* Z = (const unsigned char*)S;
- while (*Z) //0 is end
- {
- //1 byte
- if (*Z<0x80)
- {
- str += (wchar_t)(*Z);
- Z++;
- }
- //2 bytes
- else if ((*Z&0xE0)==0xC0)
- {
- if ((*(Z+1)&0xC0)==0x80)
- {
- str += (wchar_t)((((wchar_t)(*Z&0x1F))<<6)|(*(Z+1)&0x3F));
- Z+=2;
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- //3 bytes
- else if ((*Z&0xF0)==0xE0)
- {
- if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80)
- {
- str += (wchar_t)((((wchar_t)(*Z&0x0F))<<12)|((*(Z+1)&0x3F)<<6)|(*(Z+2)&0x3F));
- Z+=3;
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- //4 bytes
- else if ((*Z&0xF8)==0xF0)
- {
- if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80 && (*(Z+3)&0xC0)==0x80)
- {
- str += (wchar_t)((((wchar_t)(*Z&0x0F))<<18)|((*(Z+1)&0x3F)<<12)||((*(Z+2)&0x3F)<<6)|(*(Z+3)&0x3F));
- Z+=4;
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- return str;
+ CStringW str;
+ if (S == NULL) {
+ return str;
+ }
+
+ // Don't use MultiByteToWideChar(), some characters are not well decoded
+ const unsigned char* Z = (const unsigned char*)S;
+ while (*Z) { //0 is end
+ //1 byte
+ if (*Z < 0x80) {
+ str += (wchar_t)(*Z);
+ Z++;
+ }
+ //2 bytes
+ else if ((*Z & 0xE0) == 0xC0) {
+ if ((*(Z + 1) & 0xC0) == 0x80) {
+ str += (wchar_t)((((wchar_t)(*Z & 0x1F)) << 6) | (*(Z + 1) & 0x3F));
+ Z += 2;
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ }
+ //3 bytes
+ else if ((*Z & 0xF0) == 0xE0) {
+ if ((*(Z + 1) & 0xC0) == 0x80 && (*(Z + 2) & 0xC0) == 0x80) {
+ str += (wchar_t)((((wchar_t)(*Z & 0x0F)) << 12) | ((*(Z + 1) & 0x3F) << 6) | (*(Z + 2) & 0x3F));
+ Z += 3;
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ }
+ //4 bytes
+ else if ((*Z & 0xF8) == 0xF0) {
+ if ((*(Z + 1) & 0xC0) == 0x80 && (*(Z + 2) & 0xC0) == 0x80 && (*(Z + 3) & 0xC0) == 0x80) {
+ str += (wchar_t)((((wchar_t)(*Z & 0x0F)) << 18) | ((*(Z + 1) & 0x3F) << 12) || ((*(Z + 2) & 0x3F) << 6) | (*(Z + 3) & 0x3F));
+ Z += 4;
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ }
+ return str;
}
CStringW LocalToStringW(const char* S)
{
- CStringW str;
- if (S==NULL) {
- return str;
- }
+ CStringW str;
+ if (S == NULL) {
+ return str;
+ }
- int Size = MultiByteToWideChar(CP_ACP, 0, S, -1, NULL, 0);
- if (Size!=0) {
- str.ReleaseBuffer(MultiByteToWideChar(CP_ACP, 0, S, -1, str.GetBuffer(Size), Size+1)-1);
- }
- return str;
+ int Size = MultiByteToWideChar(CP_ACP, 0, S, -1, NULL, 0);
+ if (Size != 0) {
+ str.ReleaseBuffer(MultiByteToWideChar(CP_ACP, 0, S, -1, str.GetBuffer(Size), Size + 1) - 1);
+ }
+ return str;
}
static struct {
- LPCSTR name, iso6392, iso6391;
- LCID lcid;
-} s_isolangs[] = { // TODO : fill LCID !!!
- {"Abkhazian", "abk", "ab"},
- {"Achinese", "ace", ""},
- {"Acoli", "ach", ""},
- {"Adangme", "ada", ""},
- {"Afar", "aar", "aa"},
- {"Afrihili", "afh", ""},
- {"Afrikaans", "afr", "af", MAKELCID( MAKELANGID(LANG_AFRIKAANS, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Afro-Asiatic (Other)", "afa", ""},
- {"Akan", "aka", "ak"},
- {"Akkadian", "akk", ""},
- {"Albanian", "alb", "sq"},
- {"Albanian", "sqi", "sq", MAKELCID( MAKELANGID(LANG_ALBANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Aleut", "ale", ""},
- {"Algonquian languages", "alg", ""},
- {"Altaic (Other)", "tut", ""},
- {"Amharic", "amh", "am"},
- {"Apache languages", "apa", ""},
- {"Arabic", "ara", "ar", MAKELCID( MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Aragonese", "arg", "an"},
- {"Aramaic", "arc", ""},
- {"Arapaho", "arp", ""},
- {"Araucanian", "arn", ""},
- {"Arawak", "arw", ""},
- {"Armenian", "arm", "hy", MAKELCID( MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Armenian", "hye", "hy", MAKELCID( MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Artificial (Other)", "art", ""},
- {"Assamese", "asm", "as", MAKELCID( MAKELANGID(LANG_ASSAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Asturian; Bable", "ast", ""},
- {"Athapascan languages", "ath", ""},
- {"Australian languages", "aus", ""},
- {"Austronesian (Other)", "map", ""},
- {"Avaric", "ava", "av"},
- {"Avestan", "ave", "ae"},
- {"Awadhi", "awa", ""},
- {"Aymara", "aym", "ay"},
- {"Azerbaijani", "aze", "az", MAKELCID( MAKELANGID(LANG_AZERI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Bable; Asturian", "ast", ""},
- {"Balinese", "ban", ""},
- {"Baltic (Other)", "bat", ""},
- {"Baluchi", "bal", ""},
- {"Bambara", "bam", "bm"},
- {"Bamileke languages", "bai", ""},
- {"Banda", "bad", ""},
- {"Bantu (Other)", "bnt", ""},
- {"Basa", "bas", ""},
- {"Bashkir", "bak", "ba", MAKELCID( MAKELANGID(LANG_BASHKIR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Basque", "baq", "eu", MAKELCID( MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Basque", "eus", "eu", MAKELCID( MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Batak (Indonesia)", "btk", ""},
- {"Beja", "bej", ""},
- {"Belarusian", "bel", "be", MAKELCID( MAKELANGID(LANG_BELARUSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Bemba", "bem", ""},
- {"Bengali", "ben", "bn", MAKELCID( MAKELANGID(LANG_BENGALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Berber (Other)", "ber", ""},
- {"Bhojpuri", "bho", ""},
- {"Bihari", "bih", "bh"},
- {"Bikol", "bik", ""},
- {"Bini", "bin", ""},
- {"Bislama", "bis", "bi"},
- {"Bokmål, Norwegian; Norwegian Bokmål", "nob", "nb"},
- {"Bosnian", "bos", "bs"},
- {"Braj", "bra", ""},
- {"Breton", "bre", "br", MAKELCID( MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Buginese", "bug", ""},
- {"Bulgarian", "bul", "bg", MAKELCID( MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Buriat", "bua", ""},
- {"Burmese", "bur", "my"},
- {"Burmese", "mya", "my"},
- {"Caddo", "cad", ""},
- {"Carib", "car", ""},
- {"Spanish; Castilian", "spa", "es", MAKELCID( MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Catalan", "cat", "ca", MAKELCID( MAKELANGID(LANG_CATALAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Caucasian (Other)", "cau", ""},
- {"Cebuano", "ceb", ""},
- {"Celtic (Other)", "cel", ""},
- {"Central American Indian (Other)", "cai", ""},
- {"Chagatai", "chg", ""},
- {"Chamic languages", "cmc", ""},
- {"Chamorro", "cha", "ch"},
- {"Chechen", "che", "ce"},
- {"Cherokee", "chr", ""},
- {"Chewa; Chichewa; Nyanja", "nya", "ny"},
- {"Cheyenne", "chy", ""},
- {"Chibcha", "chb", ""},
- {"Chichewa; Chewa; Nyanja", "nya", "ny"},
- {"Chinese", "chi", "zh", MAKELCID( MAKELANGID(LANG_CHINESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Chinese", "zho", "zh"},
- {"Chinook jargon", "chn", ""},
- {"Chipewyan", "chp", ""},
- {"Choctaw", "cho", ""},
- {"Chuang; Zhuang", "zha", "za"},
- {"Church Slavic; Old Church Slavonic", "chu", "cu"},
- {"Old Church Slavonic; Old Slavonic; ", "chu", "cu"},
- {"Church Slavonic; Old Bulgarian; Church Slavic;", "chu", "cu"},
- {"Old Slavonic; Church Slavonic; Old Bulgarian;", "chu", "cu"},
- {"Church Slavic; Old Church Slavonic", "chu", "cu"},
- {"Chuukese", "chk", ""},
- {"Chuvash", "chv", "cv"},
- {"Coptic", "cop", ""},
- {"Cornish", "cor", "kw"},
- {"Corsican", "cos", "co", MAKELCID( MAKELANGID(LANG_CORSICAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Cree", "cre", "cr"},
- {"Creek", "mus", ""},
- {"Creoles and pidgins (Other)", "crp", ""},
- {"Creoles and pidgins,", "cpe", ""},
- // {"English-based (Other)", "", ""},
- {"Creoles and pidgins,", "cpf", ""},
- // {"French-based (Other)", "", ""},
- {"Creoles and pidgins,", "cpp", ""},
- // {"Portuguese-based (Other)", "", ""},
- {"Croatian", "scr", "hr", MAKELCID( MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Croatian", "hrv", "hr", MAKELCID( MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Cushitic (Other)", "cus", ""},
- {"Czech", "cze", "cs", MAKELCID( MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Czech", "ces", "cs", MAKELCID( MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dakota", "dak", ""},
- {"Danish", "dan", "da", MAKELCID( MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dargwa", "dar", ""},
- {"Dayak", "day", ""},
- {"Delaware", "del", ""},
- {"Dinka", "din", ""},
- {"Divehi", "div", "dv", MAKELCID( MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dogri", "doi", ""},
- {"Dogrib", "dgr", ""},
- {"Dravidian (Other)", "dra", ""},
- {"Duala", "dua", ""},
- {"Dutch; Flemish", "dut", "nl", MAKELCID( MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dutch; Flemish", "nld", "nl", MAKELCID( MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dutch, Middle (ca. 1050-1350)", "dum", ""},
- {"Dyula", "dyu", ""},
- {"Dzongkha", "dzo", "dz"},
- {"Efik", "efi", ""},
- {"Egyptian (Ancient)", "egy", ""},
- {"Ekajuk", "eka", ""},
- {"Elamite", "elx", ""},
- {"English", "eng", "en", MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"English, Middle (1100-1500)", "enm", ""},
- {"English, Old (ca.450-1100)", "ang", ""},
- {"Esperanto", "epo", "eo"},
- {"Estonian", "est", "et", MAKELCID( MAKELANGID(LANG_ESTONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ewe", "ewe", "ee"},
- {"Ewondo", "ewo", ""},
- {"Fang", "fan", ""},
- {"Fanti", "fat", ""},
- {"Faroese", "fao", "fo", MAKELCID( MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Fijian", "fij", "fj"},
- {"Finnish", "fin", "fi", MAKELCID( MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Finno-Ugrian (Other)", "fiu", ""},
- {"Flemish; Dutch", "dut", "nl"},
- {"Flemish; Dutch", "nld", "nl"},
- {"Fon", "fon", ""},
- {"French", "fre", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French", "fra*", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French", "fra", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French, Middle (ca.1400-1600)", "frm", ""},
- {"French, Old (842-ca.1400)", "fro", ""},
- {"Frisian", "fry", "fy", MAKELCID( MAKELANGID(LANG_FRISIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Friulian", "fur", ""},
- {"Fulah", "ful", "ff"},
- {"Ga", "gaa", ""},
- {"Gaelic; Scottish Gaelic", "gla", "gd", MAKELCID( MAKELANGID(LANG_GALICIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Gallegan", "glg", "gl"},
- {"Ganda", "lug", "lg"},
- {"Gayo", "gay", ""},
- {"Gbaya", "gba", ""},
- {"Geez", "gez", ""},
- {"Georgian", "geo", "ka", MAKELCID( MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Georgian", "kat", "ka", MAKELCID( MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German", "ger", "de", MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German", "deu", "de", MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German, Low; Saxon, Low; Low German; Low Saxon", "nds", ""},
- {"German, Middle High (ca.1050-1500)", "gmh", ""},
- {"German, Old High (ca.750-1050)", "goh", ""},
- {"Germanic (Other)", "gem", ""},
- {"Gikuyu; Kikuyu", "kik", "ki"},
- {"Gilbertese", "gil", ""},
- {"Gondi", "gon", ""},
- {"Gorontalo", "gor", ""},
- {"Gothic", "got", ""},
- {"Grebo", "grb", ""},
- {"Greek, Ancient (to 1453)", "grc", "", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greek, Modern (1453-)", "gre", "el", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greek, Modern (1453-)", "ell", "el", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greenlandic; Kalaallisut", "kal", "kl", MAKELCID( MAKELANGID(LANG_GREENLANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Guarani", "grn", "gn"},
- {"Gujarati", "guj", "gu", MAKELCID( MAKELANGID(LANG_GUJARATI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Gwich’in", "gwi", ""},
- {"Haida", "hai", ""},
- {"Hausa", "hau", "ha", MAKELCID( MAKELANGID(LANG_HAUSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hawaiian", "haw", ""},
- {"Hebrew", "heb", "he", MAKELCID( MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Herero", "her", "hz"},
- {"Hiligaynon", "hil", ""},
- {"Himachali", "him", ""},
- {"Hindi", "hin", "hi", MAKELCID( MAKELANGID(LANG_HINDI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hiri Motu", "hmo", "ho"},
- {"Hittite", "hit", ""},
- {"Hmong", "hmn", ""},
- {"Hungarian", "hun", "hu", MAKELCID( MAKELANGID(LANG_HUNGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hupa", "hup", ""},
- {"Iban", "iba", ""},
- {"Icelandic", "ice", "is", MAKELCID( MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Icelandic", "isl", "is", MAKELCID( MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ido", "ido", "io"},
- {"Igbo", "ibo", "ig", MAKELCID( MAKELANGID(LANG_IGBO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ijo", "ijo", ""},
- {"Iloko", "ilo", ""},
- {"Inari Sami", "smn", ""},
- {"Indic (Other)", "inc", ""},
- {"Indo-European (Other)", "ine", ""},
- {"Indonesian", "ind", "id", MAKELCID( MAKELANGID(LANG_INDONESIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ingush", "inh", ""},
- {"Interlingua (International", "ina", "ia"},
- // {"Auxiliary Language Association)", "", ""},
- {"Interlingue", "ile", "ie"},
- {"Inuktitut", "iku", "iu", MAKELCID( MAKELANGID(LANG_INUKTITUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Inupiaq", "ipk", "ik"},
- {"Iranian (Other)", "ira", ""},
- {"Irish", "gle", "ga", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Irish, Middle (900-1200)", "mga", "", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Irish, Old (to 900)", "sga", "", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Iroquoian languages", "iro", ""},
- {"Italian", "ita", "it", MAKELCID( MAKELANGID(LANG_ITALIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Japanese", "jpn", "ja", MAKELCID( MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Javanese", "jav", "jv"},
- {"Judeo-Arabic", "jrb", ""},
- {"Judeo-Persian", "jpr", ""},
- {"Kabardian", "kbd", ""},
- {"Kabyle", "kab", ""},
- {"Kachin", "kac", ""},
- {"Kalaallisut; Greenlandic", "kal", "kl"},
- {"Kamba", "kam", ""},
- {"Kannada", "kan", "kn", MAKELCID( MAKELANGID(LANG_KANNADA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kanuri", "kau", "kr"},
- {"Kara-Kalpak", "kaa", ""},
- {"Karen", "kar", ""},
- {"Kashmiri", "kas", "ks", MAKELCID( MAKELANGID(LANG_KASHMIRI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kawi", "kaw", ""},
- {"Kazakh", "kaz", "kk", MAKELCID( MAKELANGID(LANG_KAZAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Khasi", "kha", ""},
- {"Khmer", "khm", "km", MAKELCID( MAKELANGID(LANG_KHMER, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Khoisan (Other)", "khi", ""},
- {"Khotanese", "kho", ""},
- {"Kikuyu; Gikuyu", "kik", "ki"},
- {"Kimbundu", "kmb", ""},
- {"Kinyarwanda", "kin", "rw", MAKELCID( MAKELANGID(LANG_KINYARWANDA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kirghiz", "kir", "ky"},
- {"Komi", "kom", "kv"},
- {"Kongo", "kon", "kg"},
- {"Konkani", "kok", "", MAKELCID( MAKELANGID(LANG_KONKANI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Korean", "kor", "ko", MAKELCID( MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kosraean", "kos", ""},
- {"Kpelle", "kpe", ""},
- {"Kru", "kro", ""},
- {"Kuanyama; Kwanyama", "kua", "kj"},
- {"Kumyk", "kum", ""},
- {"Kurdish", "kur", "ku"},
- {"Kurukh", "kru", ""},
- {"Kutenai", "kut", ""},
- {"Kwanyama, Kuanyama", "kua", "kj"},
- {"Ladino", "lad", ""},
- {"Lahnda", "lah", ""},
- {"Lamba", "lam", ""},
- {"Lao", "lao", "lo", MAKELCID( MAKELANGID(LANG_LAO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Latin", "lat", "la"},
- {"Latvian", "lav", "lv", MAKELCID( MAKELANGID(LANG_LATVIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Letzeburgesch; Luxembourgish", "ltz", "lb"},
- {"Lezghian", "lez", ""},
- {"Limburgan; Limburger; Limburgish", "lim", "li"},
- {"Limburger; Limburgan; Limburgish;", "lim", "li"},
- {"Limburgish; Limburger; Limburgan", "lim", "li"},
- {"Lingala", "lin", "ln"},
- {"Lithuanian", "lit", "lt", MAKELCID( MAKELANGID(LANG_LITHUANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Low German; Low Saxon; German, Low; Saxon, Low", "nds", ""},
- {"Low Saxon; Low German; Saxon, Low; German, Low", "nds", ""},
- {"Lozi", "loz", ""},
- {"Luba-Katanga", "lub", "lu"},
- {"Luba-Lulua", "lua", ""},
- {"Luiseno", "lui", ""},
- {"Lule Sami", "smj", ""},
- {"Lunda", "lun", ""},
- {"Luo (Kenya and Tanzania)", "luo", ""},
- {"Lushai", "lus", ""},
- {"Luxembourgish; Letzeburgesch", "ltz", "lb", MAKELCID( MAKELANGID(LANG_LUXEMBOURGISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Macedonian", "mac", "mk", MAKELCID( MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Macedonian", "mkd", "mk", MAKELCID( MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Madurese", "mad", ""},
- {"Magahi", "mag", ""},
- {"Maithili", "mai", ""},
- {"Makasar", "mak", ""},
- {"Malagasy", "mlg", "mg"},
- {"Malay", "may", "ms", MAKELCID( MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Malay", "msa", "ms", MAKELCID( MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Malayalam", "mal", "ml", MAKELCID( MAKELANGID(LANG_MALAYALAM, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Maltese", "mlt", "mt", MAKELCID( MAKELANGID(LANG_MALTESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Manchu", "mnc", ""},
- {"Mandar", "mdr", ""},
- {"Mandingo", "man", ""},
- {"Manipuri", "mni", "", MAKELCID( MAKELANGID(LANG_MANIPURI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Manobo languages", "mno", ""},
- {"Manx", "glv", "gv"},
- {"Maori", "mao", "mi", MAKELCID( MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Maori", "mri", "mi", MAKELCID( MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Marathi", "mar", "mr", MAKELCID( MAKELANGID(LANG_MARATHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Mari", "chm", ""},
- {"Marshallese", "mah", "mh"},
- {"Marwari", "mwr", ""},
- {"Masai", "mas", ""},
- {"Mayan languages", "myn", ""},
- {"Mende", "men", ""},
- {"Micmac", "mic", ""},
- {"Minangkabau", "min", ""},
- {"Miscellaneous languages", "mis", ""},
- {"Mohawk", "moh", "", MAKELCID( MAKELANGID(LANG_MOHAWK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Moldavian", "mol", "mo"},
- {"Mon-Khmer (Other)", "mkh", ""},
- {"Mongo", "lol", ""},
- {"Mongolian", "mon", "mn", MAKELCID( MAKELANGID(LANG_MONGOLIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Mossi", "mos", ""},
- {"Multiple languages", "mul", ""},
- {"Munda languages", "mun", ""},
- {"Nahuatl", "nah", ""},
- {"Nauru", "nau", "na"},
- {"Navaho, Navajo", "nav", "nv"},
- {"Navajo; Navaho", "nav", "nv"},
- {"Ndebele, North", "nde", "nd"},
- {"Ndebele, South", "nbl", "nr"},
- {"Ndonga", "ndo", "ng"},
- {"Neapolitan", "nap", ""},
- {"Nepali", "nep", "ne", MAKELCID( MAKELANGID(LANG_NEPALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Newari", "new", ""},
- {"Nias", "nia", ""},
- {"Niger-Kordofanian (Other)", "nic", ""},
- {"Nilo-Saharan (Other)", "ssa", ""},
- {"Niuean", "niu", ""},
- {"Norse, Old", "non", ""},
- {"North American Indian (Other)", "nai", ""},
- {"Northern Sami", "sme", "se"},
- {"North Ndebele", "nde", "nd"},
- {"Norwegian", "nor", "no", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Norwegian Bokmål; Bokmål, Norwegian", "nob", "nb", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Norwegian Nynorsk; Nynorsk, Norwegian", "nno", "nn", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Nubian languages", "nub", ""},
- {"Nyamwezi", "nym", ""},
- {"Nyanja; Chichewa; Chewa", "nya", "ny"},
- {"Nyankole", "nyn", ""},
- {"Nynorsk, Norwegian; Norwegian Nynorsk", "nno", "nn"},
- {"Nyoro", "nyo", ""},
- {"Nzima", "nzi", ""},
- {"Occitan (post 1500},; Provençal", "oci", "oc", MAKELCID( MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ojibwa", "oji", "oj"},
- {"Old Bulgarian; Old Slavonic; Church Slavonic;", "chu", "cu"},
- {"Oriya", "ori", "or"},
- {"Oromo", "orm", "om"},
- {"Osage", "osa", ""},
- {"Ossetian; Ossetic", "oss", "os"},
- {"Ossetic; Ossetian", "oss", "os"},
- {"Otomian languages", "oto", ""},
- {"Pahlavi", "pal", ""},
- {"Palauan", "pau", ""},
- {"Pali", "pli", "pi"},
- {"Pampanga", "pam", ""},
- {"Pangasinan", "pag", ""},
- {"Panjabi", "pan", "pa"},
- {"Papiamento", "pap", ""},
- {"Papuan (Other)", "paa", ""},
- {"Persian", "per", "fa", MAKELCID( MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Persian", "fas", "fa", MAKELCID( MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Persian, Old (ca.600-400 B.C.)", "peo", ""},
- {"Philippine (Other)", "phi", ""},
- {"Phoenician", "phn", ""},
- {"Pohnpeian", "pon", ""},
- {"Polish", "pol", "pl", MAKELCID( MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Portuguese", "por", "pt", MAKELCID( MAKELANGID(LANG_PORTUGUESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Prakrit languages", "pra", ""},
- {"Provençal; Occitan (post 1500)", "oci", "oc"},
- {"Provençal, Old (to 1500)", "pro", ""},
- {"Pushto", "pus", "ps"},
- {"Quechua", "que", "qu", MAKELCID( MAKELANGID(LANG_QUECHUA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Raeto-Romance", "roh", "rm"},
- {"Rajasthani", "raj", ""},
- {"Rapanui", "rap", ""},
- {"Rarotongan", "rar", ""},
- {"Reserved for local use", "qaa-qtz", ""},
- {"Romance (Other)", "roa", ""},
- {"Romanian", "rum", "ro", MAKELCID( MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Romanian", "ron", "ro", MAKELCID( MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Romany", "rom", ""},
- {"Rundi", "run", "rn"},
- {"Russian", "rus", "ru", MAKELCID( MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Salishan languages", "sal", ""},
- {"Samaritan Aramaic", "sam", ""},
- {"Sami languages (Other)", "smi", ""},
- {"Samoan", "smo", "sm"},
- {"Sandawe", "sad", ""},
- {"Sango", "sag", "sg"},
- {"Sanskrit", "san", "sa", MAKELCID( MAKELANGID(LANG_SANSKRIT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Santali", "sat", ""},
- {"Sardinian", "srd", "sc"},
- {"Sasak", "sas", ""},
- {"Saxon, Low; German, Low; Low Saxon; Low German", "nds", ""},
- {"Scots", "sco", ""},
- {"Scottish Gaelic; Gaelic", "gla", "gd"},
- {"Selkup", "sel", ""},
- {"Semitic (Other)", "sem", ""},
- {"Serbian", "scc", "sr", MAKELCID( MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Serbian", "srp", "sr", MAKELCID( MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Serer", "srr", ""},
- {"Shan", "shn", ""},
- {"Shona", "sna", "sn"},
- {"Sichuan Yi", "iii", "ii"},
- {"Sidamo", "sid", ""},
- {"Sign languages", "sgn", ""},
- {"Siksika", "bla", ""},
- {"Sindhi", "snd", "sd", MAKELCID( MAKELANGID(LANG_SINDHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sinhalese", "sin", "si", MAKELCID( MAKELANGID(LANG_SINHALESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sino-Tibetan (Other)", "sit", ""},
- {"Siouan languages", "sio", ""},
- {"Skolt Sami", "sms", ""},
- {"Slave (Athapascan)", "den", ""},
- {"Slavic (Other)", "sla", ""},
- {"Slovak", "slo", "sk", MAKELCID( MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Slovak", "slk", "sk", MAKELCID( MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Slovenian", "slv", "sl", MAKELCID( MAKELANGID(LANG_SLOVENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sogdian", "sog", ""},
- {"Somali", "som", "so"},
- {"Songhai", "son", ""},
- {"Soninke", "snk", ""},
- {"Sorbian languages", "wen", ""},
- {"Sotho, Northern", "nso", "", MAKELCID( MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sotho, Southern", "sot", "st", MAKELCID( MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"South American Indian (Other)", "sai", ""},
- {"Southern Sami", "sma", ""},
- {"South Ndebele", "nbl", "nr"},
- {"Spanish; Castilian", "spa", "es", MAKELCID( MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sukuma", "suk", ""},
- {"Sumerian", "sux", ""},
- {"Sundanese", "sun", "su"},
- {"Susu", "sus", ""},
- {"Swahili", "swa", "sw", MAKELCID( MAKELANGID(LANG_SWAHILI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Swati", "ssw", "ss"},
- {"Swedish", "swe", "sv", MAKELCID( MAKELANGID(LANG_SWEDISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Syriac", "syr", "", MAKELCID( MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tagalog", "tgl", "tl"},
- {"Tahitian", "tah", "ty"},
- {"Tai (Other)", "tai", ""},
- {"Tajik", "tgk", "tg", MAKELCID( MAKELANGID(LANG_TAJIK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tamashek", "tmh", ""},
- {"Tamil", "tam", "ta", MAKELCID( MAKELANGID(LANG_TAMIL, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tatar", "tat", "tt", MAKELCID( MAKELANGID(LANG_TATAR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Telugu", "tel", "te", MAKELCID( MAKELANGID(LANG_TELUGU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tereno", "ter", ""},
- {"Tetum", "tet", ""},
- {"Thai", "tha", "th", MAKELCID( MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tibetan", "tib", "bo", MAKELCID( MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tibetan", "bod", "bo", MAKELCID( MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tigre", "tig", ""},
- {"Tigrinya", "tir", "ti", MAKELCID( MAKELANGID(LANG_TIGRIGNA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Timne", "tem", ""},
- {"Tiv", "tiv", ""},
- {"Tlingit", "tli", ""},
- {"Tok Pisin", "tpi", ""},
- {"Tokelau", "tkl", ""},
- {"Tonga (Nyasa)", "tog", ""},
- {"Tonga (Tonga Islands)", "ton", "to"},
- {"Tsimshian", "tsi", ""},
- {"Tsonga", "tso", "ts"},
- {"Tswana", "tsn", "tn", MAKELCID( MAKELANGID(LANG_TSWANA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tumbuka", "tum", ""},
- {"Tupi languages", "tup", ""},
- {"Turkish", "tur", "tr", MAKELCID( MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Turkish, Ottoman (1500-1928)", "ota", "", MAKELCID( MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Turkmen", "tuk", "tk", MAKELCID( MAKELANGID(LANG_TURKMEN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tuvalu", "tvl", ""},
- {"Tuvinian", "tyv", ""},
- {"Twi", "twi", "tw"},
- {"Ugaritic", "uga", ""},
- {"Uighur", "uig", "ug", MAKELCID( MAKELANGID(LANG_UIGHUR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ukrainian", "ukr", "uk", MAKELCID( MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Umbundu", "umb", ""},
- {"Undetermined", "und", ""},
- {"Urdu", "urd", "ur", MAKELCID( MAKELANGID(LANG_URDU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Uzbek", "uzb", "uz", MAKELCID( MAKELANGID(LANG_UZBEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Vai", "vai", ""},
- {"Venda", "ven", "ve"},
- {"Vietnamese", "vie", "vi", MAKELCID( MAKELANGID(LANG_VIETNAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Volapuk", "vol", "vo"},
- {"Votic", "vot", ""},
- {"Wakashan languages", "wak", ""},
- {"Walamo", "wal", ""},
- {"Walloon", "wln", "wa"},
- {"Waray", "war", ""},
- {"Washo", "was", ""},
- {"Welsh", "wel", "cy", MAKELCID( MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Welsh", "cym", "cy", MAKELCID( MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Wolof", "wol", "wo", MAKELCID( MAKELANGID(LANG_WOLOF, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Xhosa", "xho", "xh", MAKELCID( MAKELANGID(LANG_XHOSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yakut", "sah", "", MAKELCID( MAKELANGID(LANG_YAKUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yao", "yao", ""},
- {"Yapese", "yap", ""},
- {"Yiddish", "yid", "yi"},
- {"Yoruba", "yor", "yo", MAKELCID( MAKELANGID(LANG_YORUBA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yupik languages", "ypk", ""},
- {"Zande", "znd", ""},
- {"Zapotec", "zap", ""},
- {"Zenaga", "zen", ""},
- {"Zhuang; Chuang", "zha", "za"},
- {"Zulu", "zul", "zu", MAKELCID( MAKELANGID(LANG_ZULU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Zuni", "zun", ""},
- {"Classical Newari", "nwc", ""},
- {"Klingon", "tlh", ""},
- {"Blin", "byn", ""},
- {"Lojban", "jbo", ""},
- {"Lower Sorbian", "dsb", ""},
- {"Upper Sorbian", "hsb", ""},
- {"Kashubian", "csb", ""},
- {"Crimean Turkish", "crh", ""},
- {"Erzya", "myv", ""},
- {"Moksha", "mdf", ""},
- {"Karachay-Balkar", "krc", ""},
- {"Adyghe", "ady", ""},
- {"Udmurt", "udm", ""},
- {"Dargwa", "dar", ""},
- {"Ingush", "inh", ""},
- {"Nogai", "nog", ""},
- {"Haitian", "hat", "ht"},
- {"Kalmyk", "xal", ""},
- {"", "", ""},
- {"No subtitles", "---", "", (LCID)LCID_NOSUBTITLES},
+ LPCSTR name, iso6392, iso6391;
+ LCID lcid;
+} s_isolangs[] = { // TODO : fill LCID !!!
+ {"Abkhazian", "abk", "ab"},
+ {"Achinese", "ace", ""},
+ {"Acoli", "ach", ""},
+ {"Adangme", "ada", ""},
+ {"Afar", "aar", "aa"},
+ {"Afrihili", "afh", ""},
+ {"Afrikaans", "afr", "af", MAKELCID(MAKELANGID(LANG_AFRIKAANS, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Afro-Asiatic (Other)", "afa", ""},
+ {"Akan", "aka", "ak"},
+ {"Akkadian", "akk", ""},
+ {"Albanian", "alb", "sq"},
+ {"Albanian", "sqi", "sq", MAKELCID(MAKELANGID(LANG_ALBANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Aleut", "ale", ""},
+ {"Algonquian languages", "alg", ""},
+ {"Altaic (Other)", "tut", ""},
+ {"Amharic", "amh", "am"},
+ {"Apache languages", "apa", ""},
+ {"Arabic", "ara", "ar", MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Aragonese", "arg", "an"},
+ {"Aramaic", "arc", ""},
+ {"Arapaho", "arp", ""},
+ {"Araucanian", "arn", ""},
+ {"Arawak", "arw", ""},
+ {"Armenian", "arm", "hy", MAKELCID(MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Armenian", "hye", "hy", MAKELCID(MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Artificial (Other)", "art", ""},
+ {"Assamese", "asm", "as", MAKELCID(MAKELANGID(LANG_ASSAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Asturian; Bable", "ast", ""},
+ {"Athapascan languages", "ath", ""},
+ {"Australian languages", "aus", ""},
+ {"Austronesian (Other)", "map", ""},
+ {"Avaric", "ava", "av"},
+ {"Avestan", "ave", "ae"},
+ {"Awadhi", "awa", ""},
+ {"Aymara", "aym", "ay"},
+ {"Azerbaijani", "aze", "az", MAKELCID(MAKELANGID(LANG_AZERI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Bable; Asturian", "ast", ""},
+ {"Balinese", "ban", ""},
+ {"Baltic (Other)", "bat", ""},
+ {"Baluchi", "bal", ""},
+ {"Bambara", "bam", "bm"},
+ {"Bamileke languages", "bai", ""},
+ {"Banda", "bad", ""},
+ {"Bantu (Other)", "bnt", ""},
+ {"Basa", "bas", ""},
+ {"Bashkir", "bak", "ba", MAKELCID(MAKELANGID(LANG_BASHKIR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Basque", "baq", "eu", MAKELCID(MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Basque", "eus", "eu", MAKELCID(MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Batak (Indonesia)", "btk", ""},
+ {"Beja", "bej", ""},
+ {"Belarusian", "bel", "be", MAKELCID(MAKELANGID(LANG_BELARUSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Bemba", "bem", ""},
+ {"Bengali", "ben", "bn", MAKELCID(MAKELANGID(LANG_BENGALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Berber (Other)", "ber", ""},
+ {"Bhojpuri", "bho", ""},
+ {"Bihari", "bih", "bh"},
+ {"Bikol", "bik", ""},
+ {"Bini", "bin", ""},
+ {"Bislama", "bis", "bi"},
+ {"Bokmål, Norwegian; Norwegian Bokmål", "nob", "nb"},
+ {"Bosnian", "bos", "bs"},
+ {"Braj", "bra", ""},
+ {"Breton", "bre", "br", MAKELCID(MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Buginese", "bug", ""},
+ {"Bulgarian", "bul", "bg", MAKELCID(MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Buriat", "bua", ""},
+ {"Burmese", "bur", "my"},
+ {"Burmese", "mya", "my"},
+ {"Caddo", "cad", ""},
+ {"Carib", "car", ""},
+ {"Spanish; Castilian", "spa", "es", MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Catalan", "cat", "ca", MAKELCID(MAKELANGID(LANG_CATALAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Caucasian (Other)", "cau", ""},
+ {"Cebuano", "ceb", ""},
+ {"Celtic (Other)", "cel", ""},
+ {"Central American Indian (Other)", "cai", ""},
+ {"Chagatai", "chg", ""},
+ {"Chamic languages", "cmc", ""},
+ {"Chamorro", "cha", "ch"},
+ {"Chechen", "che", "ce"},
+ {"Cherokee", "chr", ""},
+ {"Chewa; Chichewa; Nyanja", "nya", "ny"},
+ {"Cheyenne", "chy", ""},
+ {"Chibcha", "chb", ""},
+ {"Chichewa; Chewa; Nyanja", "nya", "ny"},
+ {"Chinese", "chi", "zh", MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Chinese", "zho", "zh"},
+ {"Chinook jargon", "chn", ""},
+ {"Chipewyan", "chp", ""},
+ {"Choctaw", "cho", ""},
+ {"Chuang; Zhuang", "zha", "za"},
+ {"Church Slavic; Old Church Slavonic", "chu", "cu"},
+ {"Old Church Slavonic; Old Slavonic; ", "chu", "cu"},
+ {"Church Slavonic; Old Bulgarian; Church Slavic;", "chu", "cu"},
+ {"Old Slavonic; Church Slavonic; Old Bulgarian;", "chu", "cu"},
+ {"Church Slavic; Old Church Slavonic", "chu", "cu"},
+ {"Chuukese", "chk", ""},
+ {"Chuvash", "chv", "cv"},
+ {"Coptic", "cop", ""},
+ {"Cornish", "cor", "kw"},
+ {"Corsican", "cos", "co", MAKELCID(MAKELANGID(LANG_CORSICAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Cree", "cre", "cr"},
+ {"Creek", "mus", ""},
+ {"Creoles and pidgins (Other)", "crp", ""},
+ {"Creoles and pidgins,", "cpe", ""},
+ // {"English-based (Other)", "", ""},
+ {"Creoles and pidgins,", "cpf", ""},
+ // {"French-based (Other)", "", ""},
+ {"Creoles and pidgins,", "cpp", ""},
+ // {"Portuguese-based (Other)", "", ""},
+ {"Croatian", "scr", "hr", MAKELCID(MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Croatian", "hrv", "hr", MAKELCID(MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Cushitic (Other)", "cus", ""},
+ {"Czech", "cze", "cs", MAKELCID(MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Czech", "ces", "cs", MAKELCID(MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dakota", "dak", ""},
+ {"Danish", "dan", "da", MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dargwa", "dar", ""},
+ {"Dayak", "day", ""},
+ {"Delaware", "del", ""},
+ {"Dinka", "din", ""},
+ {"Divehi", "div", "dv", MAKELCID(MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dogri", "doi", ""},
+ {"Dogrib", "dgr", ""},
+ {"Dravidian (Other)", "dra", ""},
+ {"Duala", "dua", ""},
+ {"Dutch; Flemish", "dut", "nl", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dutch; Flemish", "nld", "nl", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dutch, Middle (ca. 1050-1350)", "dum", ""},
+ {"Dyula", "dyu", ""},
+ {"Dzongkha", "dzo", "dz"},
+ {"Efik", "efi", ""},
+ {"Egyptian (Ancient)", "egy", ""},
+ {"Ekajuk", "eka", ""},
+ {"Elamite", "elx", ""},
+ {"English", "eng", "en", MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"English, Middle (1100-1500)", "enm", ""},
+ {"English, Old (ca.450-1100)", "ang", ""},
+ {"Esperanto", "epo", "eo"},
+ {"Estonian", "est", "et", MAKELCID(MAKELANGID(LANG_ESTONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ewe", "ewe", "ee"},
+ {"Ewondo", "ewo", ""},
+ {"Fang", "fan", ""},
+ {"Fanti", "fat", ""},
+ {"Faroese", "fao", "fo", MAKELCID(MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Fijian", "fij", "fj"},
+ {"Finnish", "fin", "fi", MAKELCID(MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Finno-Ugrian (Other)", "fiu", ""},
+ {"Flemish; Dutch", "dut", "nl"},
+ {"Flemish; Dutch", "nld", "nl"},
+ {"Fon", "fon", ""},
+ {"French", "fre", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French", "fra*", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French", "fra", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French, Middle (ca.1400-1600)", "frm", ""},
+ {"French, Old (842-ca.1400)", "fro", ""},
+ {"Frisian", "fry", "fy", MAKELCID(MAKELANGID(LANG_FRISIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Friulian", "fur", ""},
+ {"Fulah", "ful", "ff"},
+ {"Ga", "gaa", ""},
+ {"Gaelic; Scottish Gaelic", "gla", "gd", MAKELCID(MAKELANGID(LANG_GALICIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Gallegan", "glg", "gl"},
+ {"Ganda", "lug", "lg"},
+ {"Gayo", "gay", ""},
+ {"Gbaya", "gba", ""},
+ {"Geez", "gez", ""},
+ {"Georgian", "geo", "ka", MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Georgian", "kat", "ka", MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German", "ger", "de", MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German", "deu", "de", MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German, Low; Saxon, Low; Low German; Low Saxon", "nds", ""},
+ {"German, Middle High (ca.1050-1500)", "gmh", ""},
+ {"German, Old High (ca.750-1050)", "goh", ""},
+ {"Germanic (Other)", "gem", ""},
+ {"Gikuyu; Kikuyu", "kik", "ki"},
+ {"Gilbertese", "gil", ""},
+ {"Gondi", "gon", ""},
+ {"Gorontalo", "gor", ""},
+ {"Gothic", "got", ""},
+ {"Grebo", "grb", ""},
+ {"Greek, Ancient (to 1453)", "grc", "", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greek, Modern (1453-)", "gre", "el", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greek, Modern (1453-)", "ell", "el", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greenlandic; Kalaallisut", "kal", "kl", MAKELCID(MAKELANGID(LANG_GREENLANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Guarani", "grn", "gn"},
+ {"Gujarati", "guj", "gu", MAKELCID(MAKELANGID(LANG_GUJARATI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Gwich’in", "gwi", ""},
+ {"Haida", "hai", ""},
+ {"Hausa", "hau", "ha", MAKELCID(MAKELANGID(LANG_HAUSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hawaiian", "haw", ""},
+ {"Hebrew", "heb", "he", MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Herero", "her", "hz"},
+ {"Hiligaynon", "hil", ""},
+ {"Himachali", "him", ""},
+ {"Hindi", "hin", "hi", MAKELCID(MAKELANGID(LANG_HINDI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hiri Motu", "hmo", "ho"},
+ {"Hittite", "hit", ""},
+ {"Hmong", "hmn", ""},
+ {"Hungarian", "hun", "hu", MAKELCID(MAKELANGID(LANG_HUNGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hupa", "hup", ""},
+ {"Iban", "iba", ""},
+ {"Icelandic", "ice", "is", MAKELCID(MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Icelandic", "isl", "is", MAKELCID(MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ido", "ido", "io"},
+ {"Igbo", "ibo", "ig", MAKELCID(MAKELANGID(LANG_IGBO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ijo", "ijo", ""},
+ {"Iloko", "ilo", ""},
+ {"Inari Sami", "smn", ""},
+ {"Indic (Other)", "inc", ""},
+ {"Indo-European (Other)", "ine", ""},
+ {"Indonesian", "ind", "id", MAKELCID(MAKELANGID(LANG_INDONESIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ingush", "inh", ""},
+ {"Interlingua (International", "ina", "ia"},
+ // {"Auxiliary Language Association)", "", ""},
+ {"Interlingue", "ile", "ie"},
+ {"Inuktitut", "iku", "iu", MAKELCID(MAKELANGID(LANG_INUKTITUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Inupiaq", "ipk", "ik"},
+ {"Iranian (Other)", "ira", ""},
+ {"Irish", "gle", "ga", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Irish, Middle (900-1200)", "mga", "", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Irish, Old (to 900)", "sga", "", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Iroquoian languages", "iro", ""},
+ {"Italian", "ita", "it", MAKELCID(MAKELANGID(LANG_ITALIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Japanese", "jpn", "ja", MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Javanese", "jav", "jv"},
+ {"Judeo-Arabic", "jrb", ""},
+ {"Judeo-Persian", "jpr", ""},
+ {"Kabardian", "kbd", ""},
+ {"Kabyle", "kab", ""},
+ {"Kachin", "kac", ""},
+ {"Kalaallisut; Greenlandic", "kal", "kl"},
+ {"Kamba", "kam", ""},
+ {"Kannada", "kan", "kn", MAKELCID(MAKELANGID(LANG_KANNADA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kanuri", "kau", "kr"},
+ {"Kara-Kalpak", "kaa", ""},
+ {"Karen", "kar", ""},
+ {"Kashmiri", "kas", "ks", MAKELCID(MAKELANGID(LANG_KASHMIRI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kawi", "kaw", ""},
+ {"Kazakh", "kaz", "kk", MAKELCID(MAKELANGID(LANG_KAZAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Khasi", "kha", ""},
+ {"Khmer", "khm", "km", MAKELCID(MAKELANGID(LANG_KHMER, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Khoisan (Other)", "khi", ""},
+ {"Khotanese", "kho", ""},
+ {"Kikuyu; Gikuyu", "kik", "ki"},
+ {"Kimbundu", "kmb", ""},
+ {"Kinyarwanda", "kin", "rw", MAKELCID(MAKELANGID(LANG_KINYARWANDA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kirghiz", "kir", "ky"},
+ {"Komi", "kom", "kv"},
+ {"Kongo", "kon", "kg"},
+ {"Konkani", "kok", "", MAKELCID(MAKELANGID(LANG_KONKANI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Korean", "kor", "ko", MAKELCID(MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kosraean", "kos", ""},
+ {"Kpelle", "kpe", ""},
+ {"Kru", "kro", ""},
+ {"Kuanyama; Kwanyama", "kua", "kj"},
+ {"Kumyk", "kum", ""},
+ {"Kurdish", "kur", "ku"},
+ {"Kurukh", "kru", ""},
+ {"Kutenai", "kut", ""},
+ {"Kwanyama, Kuanyama", "kua", "kj"},
+ {"Ladino", "lad", ""},
+ {"Lahnda", "lah", ""},
+ {"Lamba", "lam", ""},
+ {"Lao", "lao", "lo", MAKELCID(MAKELANGID(LANG_LAO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Latin", "lat", "la"},
+ {"Latvian", "lav", "lv", MAKELCID(MAKELANGID(LANG_LATVIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Letzeburgesch; Luxembourgish", "ltz", "lb"},
+ {"Lezghian", "lez", ""},
+ {"Limburgan; Limburger; Limburgish", "lim", "li"},
+ {"Limburger; Limburgan; Limburgish;", "lim", "li"},
+ {"Limburgish; Limburger; Limburgan", "lim", "li"},
+ {"Lingala", "lin", "ln"},
+ {"Lithuanian", "lit", "lt", MAKELCID(MAKELANGID(LANG_LITHUANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Low German; Low Saxon; German, Low; Saxon, Low", "nds", ""},
+ {"Low Saxon; Low German; Saxon, Low; German, Low", "nds", ""},
+ {"Lozi", "loz", ""},
+ {"Luba-Katanga", "lub", "lu"},
+ {"Luba-Lulua", "lua", ""},
+ {"Luiseno", "lui", ""},
+ {"Lule Sami", "smj", ""},
+ {"Lunda", "lun", ""},
+ {"Luo (Kenya and Tanzania)", "luo", ""},
+ {"Lushai", "lus", ""},
+ {"Luxembourgish; Letzeburgesch", "ltz", "lb", MAKELCID(MAKELANGID(LANG_LUXEMBOURGISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Macedonian", "mac", "mk", MAKELCID(MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Macedonian", "mkd", "mk", MAKELCID(MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Madurese", "mad", ""},
+ {"Magahi", "mag", ""},
+ {"Maithili", "mai", ""},
+ {"Makasar", "mak", ""},
+ {"Malagasy", "mlg", "mg"},
+ {"Malay", "may", "ms", MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Malay", "msa", "ms", MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Malayalam", "mal", "ml", MAKELCID(MAKELANGID(LANG_MALAYALAM, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Maltese", "mlt", "mt", MAKELCID(MAKELANGID(LANG_MALTESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Manchu", "mnc", ""},
+ {"Mandar", "mdr", ""},
+ {"Mandingo", "man", ""},
+ {"Manipuri", "mni", "", MAKELCID(MAKELANGID(LANG_MANIPURI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Manobo languages", "mno", ""},
+ {"Manx", "glv", "gv"},
+ {"Maori", "mao", "mi", MAKELCID(MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Maori", "mri", "mi", MAKELCID(MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Marathi", "mar", "mr", MAKELCID(MAKELANGID(LANG_MARATHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Mari", "chm", ""},
+ {"Marshallese", "mah", "mh"},
+ {"Marwari", "mwr", ""},
+ {"Masai", "mas", ""},
+ {"Mayan languages", "myn", ""},
+ {"Mende", "men", ""},
+ {"Micmac", "mic", ""},
+ {"Minangkabau", "min", ""},
+ {"Miscellaneous languages", "mis", ""},
+ {"Mohawk", "moh", "", MAKELCID(MAKELANGID(LANG_MOHAWK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Moldavian", "mol", "mo"},
+ {"Mon-Khmer (Other)", "mkh", ""},
+ {"Mongo", "lol", ""},
+ {"Mongolian", "mon", "mn", MAKELCID(MAKELANGID(LANG_MONGOLIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Mossi", "mos", ""},
+ {"Multiple languages", "mul", ""},
+ {"Munda languages", "mun", ""},
+ {"Nahuatl", "nah", ""},
+ {"Nauru", "nau", "na"},
+ {"Navaho, Navajo", "nav", "nv"},
+ {"Navajo; Navaho", "nav", "nv"},
+ {"Ndebele, North", "nde", "nd"},
+ {"Ndebele, South", "nbl", "nr"},
+ {"Ndonga", "ndo", "ng"},
+ {"Neapolitan", "nap", ""},
+ {"Nepali", "nep", "ne", MAKELCID(MAKELANGID(LANG_NEPALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Newari", "new", ""},
+ {"Nias", "nia", ""},
+ {"Niger-Kordofanian (Other)", "nic", ""},
+ {"Nilo-Saharan (Other)", "ssa", ""},
+ {"Niuean", "niu", ""},
+ {"Norse, Old", "non", ""},
+ {"North American Indian (Other)", "nai", ""},
+ {"Northern Sami", "sme", "se"},
+ {"North Ndebele", "nde", "nd"},
+ {"Norwegian", "nor", "no", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Norwegian Bokmål; Bokmål, Norwegian", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Norwegian Nynorsk; Nynorsk, Norwegian", "nno", "nn", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Nubian languages", "nub", ""},
+ {"Nyamwezi", "nym", ""},
+ {"Nyanja; Chichewa; Chewa", "nya", "ny"},
+ {"Nyankole", "nyn", ""},
+ {"Nynorsk, Norwegian; Norwegian Nynorsk", "nno", "nn"},
+ {"Nyoro", "nyo", ""},
+ {"Nzima", "nzi", ""},
+ {"Occitan (post 1500},; Provençal", "oci", "oc", MAKELCID(MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ojibwa", "oji", "oj"},
+ {"Old Bulgarian; Old Slavonic; Church Slavonic;", "chu", "cu"},
+ {"Oriya", "ori", "or"},
+ {"Oromo", "orm", "om"},
+ {"Osage", "osa", ""},
+ {"Ossetian; Ossetic", "oss", "os"},
+ {"Ossetic; Ossetian", "oss", "os"},
+ {"Otomian languages", "oto", ""},
+ {"Pahlavi", "pal", ""},
+ {"Palauan", "pau", ""},
+ {"Pali", "pli", "pi"},
+ {"Pampanga", "pam", ""},
+ {"Pangasinan", "pag", ""},
+ {"Panjabi", "pan", "pa"},
+ {"Papiamento", "pap", ""},
+ {"Papuan (Other)", "paa", ""},
+ {"Persian", "per", "fa", MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Persian", "fas", "fa", MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Persian, Old (ca.600-400 B.C.)", "peo", ""},
+ {"Philippine (Other)", "phi", ""},
+ {"Phoenician", "phn", ""},
+ {"Pohnpeian", "pon", ""},
+ {"Polish", "pol", "pl", MAKELCID(MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Portuguese", "por", "pt", MAKELCID(MAKELANGID(LANG_PORTUGUESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Prakrit languages", "pra", ""},
+ {"Provençal; Occitan (post 1500)", "oci", "oc"},
+ {"Provençal, Old (to 1500)", "pro", ""},
+ {"Pushto", "pus", "ps"},
+ {"Quechua", "que", "qu", MAKELCID(MAKELANGID(LANG_QUECHUA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Raeto-Romance", "roh", "rm"},
+ {"Rajasthani", "raj", ""},
+ {"Rapanui", "rap", ""},
+ {"Rarotongan", "rar", ""},
+ {"Reserved for local use", "qaa-qtz", ""},
+ {"Romance (Other)", "roa", ""},
+ {"Romanian", "rum", "ro", MAKELCID(MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Romanian", "ron", "ro", MAKELCID(MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Romany", "rom", ""},
+ {"Rundi", "run", "rn"},
+ {"Russian", "rus", "ru", MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Salishan languages", "sal", ""},
+ {"Samaritan Aramaic", "sam", ""},
+ {"Sami languages (Other)", "smi", ""},
+ {"Samoan", "smo", "sm"},
+ {"Sandawe", "sad", ""},
+ {"Sango", "sag", "sg"},
+ {"Sanskrit", "san", "sa", MAKELCID(MAKELANGID(LANG_SANSKRIT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Santali", "sat", ""},
+ {"Sardinian", "srd", "sc"},
+ {"Sasak", "sas", ""},
+ {"Saxon, Low; German, Low; Low Saxon; Low German", "nds", ""},
+ {"Scots", "sco", ""},
+ {"Scottish Gaelic; Gaelic", "gla", "gd"},
+ {"Selkup", "sel", ""},
+ {"Semitic (Other)", "sem", ""},
+ {"Serbian", "scc", "sr", MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Serbian", "srp", "sr", MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Serer", "srr", ""},
+ {"Shan", "shn", ""},
+ {"Shona", "sna", "sn"},
+ {"Sichuan Yi", "iii", "ii"},
+ {"Sidamo", "sid", ""},
+ {"Sign languages", "sgn", ""},
+ {"Siksika", "bla", ""},
+ {"Sindhi", "snd", "sd", MAKELCID(MAKELANGID(LANG_SINDHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sinhalese", "sin", "si", MAKELCID(MAKELANGID(LANG_SINHALESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sino-Tibetan (Other)", "sit", ""},
+ {"Siouan languages", "sio", ""},
+ {"Skolt Sami", "sms", ""},
+ {"Slave (Athapascan)", "den", ""},
+ {"Slavic (Other)", "sla", ""},
+ {"Slovak", "slo", "sk", MAKELCID(MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Slovak", "slk", "sk", MAKELCID(MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Slovenian", "slv", "sl", MAKELCID(MAKELANGID(LANG_SLOVENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sogdian", "sog", ""},
+ {"Somali", "som", "so"},
+ {"Songhai", "son", ""},
+ {"Soninke", "snk", ""},
+ {"Sorbian languages", "wen", ""},
+ {"Sotho, Northern", "nso", "", MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sotho, Southern", "sot", "st", MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"South American Indian (Other)", "sai", ""},
+ {"Southern Sami", "sma", ""},
+ {"South Ndebele", "nbl", "nr"},
+ {"Spanish; Castilian", "spa", "es", MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sukuma", "suk", ""},
+ {"Sumerian", "sux", ""},
+ {"Sundanese", "sun", "su"},
+ {"Susu", "sus", ""},
+ {"Swahili", "swa", "sw", MAKELCID(MAKELANGID(LANG_SWAHILI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Swati", "ssw", "ss"},
+ {"Swedish", "swe", "sv", MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Syriac", "syr", "", MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tagalog", "tgl", "tl"},
+ {"Tahitian", "tah", "ty"},
+ {"Tai (Other)", "tai", ""},
+ {"Tajik", "tgk", "tg", MAKELCID(MAKELANGID(LANG_TAJIK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tamashek", "tmh", ""},
+ {"Tamil", "tam", "ta", MAKELCID(MAKELANGID(LANG_TAMIL, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tatar", "tat", "tt", MAKELCID(MAKELANGID(LANG_TATAR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Telugu", "tel", "te", MAKELCID(MAKELANGID(LANG_TELUGU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tereno", "ter", ""},
+ {"Tetum", "tet", ""},
+ {"Thai", "tha", "th", MAKELCID(MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tibetan", "tib", "bo", MAKELCID(MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tibetan", "bod", "bo", MAKELCID(MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tigre", "tig", ""},
+ {"Tigrinya", "tir", "ti", MAKELCID(MAKELANGID(LANG_TIGRIGNA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Timne", "tem", ""},
+ {"Tiv", "tiv", ""},
+ {"Tlingit", "tli", ""},
+ {"Tok Pisin", "tpi", ""},
+ {"Tokelau", "tkl", ""},
+ {"Tonga (Nyasa)", "tog", ""},
+ {"Tonga (Tonga Islands)", "ton", "to"},
+ {"Tsimshian", "tsi", ""},
+ {"Tsonga", "tso", "ts"},
+ {"Tswana", "tsn", "tn", MAKELCID(MAKELANGID(LANG_TSWANA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tumbuka", "tum", ""},
+ {"Tupi languages", "tup", ""},
+ {"Turkish", "tur", "tr", MAKELCID(MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Turkish, Ottoman (1500-1928)", "ota", "", MAKELCID(MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Turkmen", "tuk", "tk", MAKELCID(MAKELANGID(LANG_TURKMEN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tuvalu", "tvl", ""},
+ {"Tuvinian", "tyv", ""},
+ {"Twi", "twi", "tw"},
+ {"Ugaritic", "uga", ""},
+ {"Uighur", "uig", "ug", MAKELCID(MAKELANGID(LANG_UIGHUR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ukrainian", "ukr", "uk", MAKELCID(MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Umbundu", "umb", ""},
+ {"Undetermined", "und", ""},
+ {"Urdu", "urd", "ur", MAKELCID(MAKELANGID(LANG_URDU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Uzbek", "uzb", "uz", MAKELCID(MAKELANGID(LANG_UZBEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Vai", "vai", ""},
+ {"Venda", "ven", "ve"},
+ {"Vietnamese", "vie", "vi", MAKELCID(MAKELANGID(LANG_VIETNAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Volapuk", "vol", "vo"},
+ {"Votic", "vot", ""},
+ {"Wakashan languages", "wak", ""},
+ {"Walamo", "wal", ""},
+ {"Walloon", "wln", "wa"},
+ {"Waray", "war", ""},
+ {"Washo", "was", ""},
+ {"Welsh", "wel", "cy", MAKELCID(MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Welsh", "cym", "cy", MAKELCID(MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Wolof", "wol", "wo", MAKELCID(MAKELANGID(LANG_WOLOF, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Xhosa", "xho", "xh", MAKELCID(MAKELANGID(LANG_XHOSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yakut", "sah", "", MAKELCID(MAKELANGID(LANG_YAKUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yao", "yao", ""},
+ {"Yapese", "yap", ""},
+ {"Yiddish", "yid", "yi"},
+ {"Yoruba", "yor", "yo", MAKELCID(MAKELANGID(LANG_YORUBA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yupik languages", "ypk", ""},
+ {"Zande", "znd", ""},
+ {"Zapotec", "zap", ""},
+ {"Zenaga", "zen", ""},
+ {"Zhuang; Chuang", "zha", "za"},
+ {"Zulu", "zul", "zu", MAKELCID(MAKELANGID(LANG_ZULU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Zuni", "zun", ""},
+ {"Classical Newari", "nwc", ""},
+ {"Klingon", "tlh", ""},
+ {"Blin", "byn", ""},
+ {"Lojban", "jbo", ""},
+ {"Lower Sorbian", "dsb", ""},
+ {"Upper Sorbian", "hsb", ""},
+ {"Kashubian", "csb", ""},
+ {"Crimean Turkish", "crh", ""},
+ {"Erzya", "myv", ""},
+ {"Moksha", "mdf", ""},
+ {"Karachay-Balkar", "krc", ""},
+ {"Adyghe", "ady", ""},
+ {"Udmurt", "udm", ""},
+ {"Dargwa", "dar", ""},
+ {"Ingush", "inh", ""},
+ {"Nogai", "nog", ""},
+ {"Haitian", "hat", "ht"},
+ {"Kalmyk", "xal", ""},
+ {"", "", ""},
+ {"No subtitles", "---", "", (LCID)LCID_NOSUBTITLES},
};
CString ISO6391ToLanguage(LPCSTR code)
{
- CHAR tmp[2+1];
- strncpy_s(tmp, code, 2);
- tmp[2] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
- if (!strcmp(s_isolangs[i].iso6391, tmp)) {
- CString ret = CString(CStringA(s_isolangs[i].name));
- int i = ret.Find(';');
- if (i > 0) {
- ret = ret.Left(i);
- }
- return ret;
- }
- return _T("");
+ CHAR tmp[2 + 1];
+ strncpy_s(tmp, code, 2);
+ tmp[2] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6391, tmp)) {
+ CString ret = CString(CStringA(s_isolangs[i].name));
+ int i = ret.Find(';');
+ if (i > 0) {
+ ret = ret.Left(i);
+ }
+ return ret;
+ }
+ return _T("");
}
CString ISO6392ToLanguage(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- if (!strcmp(s_isolangs[i].iso6392, tmp)) {
- CString ret = CString(CStringA(s_isolangs[i].name));
- int i = ret.Find(';');
- if (i > 0) {
- ret = ret.Left(i);
- }
- return ret;
- }
- }
- return CString(code);
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
+ CString ret = CString(CStringA(s_isolangs[i].name));
+ int i = ret.Find(';');
+ if (i > 0) {
+ ret = ret.Left(i);
+ }
+ return ret;
+ }
+ }
+ return CString(code);
}
LCID ISO6391ToLcid(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- if (!strcmp(s_isolangs[i].iso6391, code)) {
- return s_isolangs[i].lcid;
- }
- }
- return 0;
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6391, code)) {
+ return s_isolangs[i].lcid;
+ }
+ }
+ return 0;
}
LCID ISO6392ToLcid(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- if (!strcmp(s_isolangs[i].iso6392, tmp)) {
- return s_isolangs[i].lcid;
- }
- }
- return 0;
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
+ return s_isolangs[i].lcid;
+ }
+ }
+ return 0;
}
CString ISO6391To6392(LPCSTR code)
{
- CHAR tmp[2+1];
- strncpy_s(tmp, code, 2);
- tmp[2] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
- if (!strcmp(s_isolangs[i].iso6391, tmp)) {
- return CString(CStringA(s_isolangs[i].iso6392));
- }
- return _T("");
+ CHAR tmp[2 + 1];
+ strncpy_s(tmp, code, 2);
+ tmp[2] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6391, tmp)) {
+ return CString(CStringA(s_isolangs[i].iso6392));
+ }
+ return _T("");
}
CString ISO6392To6391(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
- if (!strcmp(s_isolangs[i].iso6392, tmp)) {
- return CString(CStringA(s_isolangs[i].iso6391));
- }
- return _T("");
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
+ return CString(CStringA(s_isolangs[i].iso6391));
+ }
+ return _T("");
}
CString LanguageToISO6392(LPCTSTR lang)
{
- CString str = lang;
- str.MakeLower();
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- CAtlList<CString> sl;
- Explode(CString(s_isolangs[i].name), sl, ';');
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- if (!str.CompareNoCase(sl.GetNext(pos))) {
- return CString(s_isolangs[i].iso6392);
- }
- }
- }
- return _T("");
+ CString str = lang;
+ str.MakeLower();
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ CAtlList<CString> sl;
+ Explode(CString(s_isolangs[i].name), sl, ';');
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ if (!str.CompareNoCase(sl.GetNext(pos))) {
+ return CString(s_isolangs[i].iso6392);
+ }
+ }
+ }
+ return _T("");
}
int MakeAACInitData(BYTE* pData, int profile, int freq, int channels)
{
- int srate_idx;
-
- if (92017 <= freq) {
- srate_idx = 0;
- } else if (75132 <= freq) {
- srate_idx = 1;
- } else if (55426 <= freq) {
- srate_idx = 2;
- } else if (46009 <= freq) {
- srate_idx = 3;
- } else if (37566 <= freq) {
- srate_idx = 4;
- } else if (27713 <= freq) {
- srate_idx = 5;
- } else if (23004 <= freq) {
- srate_idx = 6;
- } else if (18783 <= freq) {
- srate_idx = 7;
- } else if (13856 <= freq) {
- srate_idx = 8;
- } else if (11502 <= freq) {
- srate_idx = 9;
- } else if (9391 <= freq) {
- srate_idx = 10;
- } else {
- srate_idx = 11;
- }
-
- pData[0] = ((abs(profile) + 1) << 3) | ((srate_idx & 0xe) >> 1);
- pData[1] = ((srate_idx & 0x1) << 7) | (channels << 3);
-
- int ret = 2;
-
- if (profile < 0) {
- freq *= 2;
-
- if (92017 <= freq) {
- srate_idx = 0;
- } else if (75132 <= freq) {
- srate_idx = 1;
- } else if (55426 <= freq) {
- srate_idx = 2;
- } else if (46009 <= freq) {
- srate_idx = 3;
- } else if (37566 <= freq) {
- srate_idx = 4;
- } else if (27713 <= freq) {
- srate_idx = 5;
- } else if (23004 <= freq) {
- srate_idx = 6;
- } else if (18783 <= freq) {
- srate_idx = 7;
- } else if (13856 <= freq) {
- srate_idx = 8;
- } else if (11502 <= freq) {
- srate_idx = 9;
- } else if (9391 <= freq) {
- srate_idx = 10;
- } else {
- srate_idx = 11;
- }
-
- pData[2] = 0x2B7>>3;
- pData[3] = (BYTE)((0x2B7<<5) | 5);
- pData[4] = (1<<7) | (srate_idx<<3);
-
- ret = 5;
- }
-
- return ret;
+ int srate_idx;
+
+ if (92017 <= freq) {
+ srate_idx = 0;
+ } else if (75132 <= freq) {
+ srate_idx = 1;
+ } else if (55426 <= freq) {
+ srate_idx = 2;
+ } else if (46009 <= freq) {
+ srate_idx = 3;
+ } else if (37566 <= freq) {
+ srate_idx = 4;
+ } else if (27713 <= freq) {
+ srate_idx = 5;
+ } else if (23004 <= freq) {
+ srate_idx = 6;
+ } else if (18783 <= freq) {
+ srate_idx = 7;
+ } else if (13856 <= freq) {
+ srate_idx = 8;
+ } else if (11502 <= freq) {
+ srate_idx = 9;
+ } else if (9391 <= freq) {
+ srate_idx = 10;
+ } else {
+ srate_idx = 11;
+ }
+
+ pData[0] = ((abs(profile) + 1) << 3) | ((srate_idx & 0xe) >> 1);
+ pData[1] = ((srate_idx & 0x1) << 7) | (channels << 3);
+
+ int ret = 2;
+
+ if (profile < 0) {
+ freq *= 2;
+
+ if (92017 <= freq) {
+ srate_idx = 0;
+ } else if (75132 <= freq) {
+ srate_idx = 1;
+ } else if (55426 <= freq) {
+ srate_idx = 2;
+ } else if (46009 <= freq) {
+ srate_idx = 3;
+ } else if (37566 <= freq) {
+ srate_idx = 4;
+ } else if (27713 <= freq) {
+ srate_idx = 5;
+ } else if (23004 <= freq) {
+ srate_idx = 6;
+ } else if (18783 <= freq) {
+ srate_idx = 7;
+ } else if (13856 <= freq) {
+ srate_idx = 8;
+ } else if (11502 <= freq) {
+ srate_idx = 9;
+ } else if (9391 <= freq) {
+ srate_idx = 10;
+ } else {
+ srate_idx = 11;
+ }
+
+ pData[2] = 0x2B7 >> 3;
+ pData[3] = (BYTE)((0x2B7 << 5) | 5);
+ pData[4] = (1 << 7) | (srate_idx << 3);
+
+ ret = 5;
+ }
+
+ return ret;
}
BOOL CFileGetStatus(LPCTSTR lpszFileName, CFileStatus& status)
{
- try {
- return CFile::GetStatus(lpszFileName, status);
- } catch (CException* e) {
- // MFCBUG: E_INVALIDARG / "Parameter is incorrect" is thrown for certain cds (vs2003)
- // http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&threadm=OZuXYRzWDHA.536%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1
- TRACE(_T("CFile::GetStatus has thrown an exception\n"));
- e->Delete();
- return false;
- }
+ try {
+ return CFile::GetStatus(lpszFileName, status);
+ } catch (CException* e) {
+ // MFCBUG: E_INVALIDARG / "Parameter is incorrect" is thrown for certain cds (vs2003)
+ // http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&threadm=OZuXYRzWDHA.536%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1
+ TRACE(_T("CFile::GetStatus has thrown an exception\n"));
+ e->Delete();
+ return false;
+ }
}
// filter registration helpers
bool DeleteRegKey(LPCTSTR pszKey, LPCTSTR pszSubkey)
{
- bool bOK = false;
+ bool bOK = false;
- HKEY hKey;
- LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
- if (ec == ERROR_SUCCESS) {
- if (pszSubkey != 0) {
- ec = ::RegDeleteKey(hKey, pszSubkey);
- }
+ HKEY hKey;
+ LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
+ if (ec == ERROR_SUCCESS) {
+ if (pszSubkey != 0) {
+ ec = ::RegDeleteKey(hKey, pszSubkey);
+ }
- bOK = (ec == ERROR_SUCCESS);
+ bOK = (ec == ERROR_SUCCESS);
- ::RegCloseKey(hKey);
- }
+ ::RegCloseKey(hKey);
+ }
- return bOK;
+ return bOK;
}
bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValueName, LPCTSTR pszValue)
{
- bool bOK = false;
+ bool bOK = false;
- CString szKey(pszKey);
- if (pszSubkey != 0) {
- szKey += CString(_T("\\")) + pszSubkey;
- }
+ CString szKey(pszKey);
+ if (pszSubkey != 0) {
+ szKey += CString(_T("\\")) + pszSubkey;
+ }
- HKEY hKey;
- LONG ec = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);
- if (ec == ERROR_SUCCESS) {
- if (pszValue != 0) {
- ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
- reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
- (DWORD)(_tcslen(pszValue) + 1) * sizeof(TCHAR));
- }
+ HKEY hKey;
+ LONG ec = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);
+ if (ec == ERROR_SUCCESS) {
+ if (pszValue != 0) {
+ ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
+ reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
+ (DWORD)(_tcslen(pszValue) + 1) * sizeof(TCHAR));
+ }
- bOK = (ec == ERROR_SUCCESS);
+ bOK = (ec == ERROR_SUCCESS);
- ::RegCloseKey(hKey);
- }
+ ::RegCloseKey(hKey);
+ }
- return bOK;
+ return bOK;
}
bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValue)
{
- return SetRegKeyValue(pszKey, pszSubkey, 0, pszValue);
+ return SetRegKeyValue(pszKey, pszSubkey, 0, pszValue);
}
void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, LPCTSTR chkbytes, LPCTSTR ext, ...)
{
- CString null = CStringFromGUID(GUID_NULL);
- CString majortype = CStringFromGUID(MEDIATYPE_Stream);
- CString subtype = CStringFromGUID(subtype2);
+ CString null = CStringFromGUID(GUID_NULL);
+ CString majortype = CStringFromGUID(MEDIATYPE_Stream);
+ CString subtype = CStringFromGUID(subtype2);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("0"), chkbytes);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("0"), chkbytes);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
- DeleteRegKey(_T("Media Type\\") + null, subtype);
+ DeleteRegKey(_T("Media Type\\") + null, subtype);
- va_list marker;
- va_start(marker, ext);
- for (; ext; ext = va_arg(marker, LPCTSTR)) {
- DeleteRegKey(_T("Media Type\\Extensions"), ext);
- }
- va_end(marker);
+ va_list marker;
+ va_start(marker, ext);
+ for (; ext; ext = va_arg(marker, LPCTSTR)) {
+ DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ }
+ va_end(marker);
}
void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlList<CString>& chkbytes, LPCTSTR ext, ...)
{
- CString null = CStringFromGUID(GUID_NULL);
- CString majortype = CStringFromGUID(MEDIATYPE_Stream);
- CString subtype = CStringFromGUID(subtype2);
+ CString null = CStringFromGUID(GUID_NULL);
+ CString majortype = CStringFromGUID(MEDIATYPE_Stream);
+ CString subtype = CStringFromGUID(subtype2);
- POSITION pos = chkbytes.GetHeadPosition();
- for (ptrdiff_t i = 0; pos; i++) {
- CString idx;
- idx.Format(_T("%d"), i);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
- }
+ POSITION pos = chkbytes.GetHeadPosition();
+ for (ptrdiff_t i = 0; pos; i++) {
+ CString idx;
+ idx.Format(_T("%d"), i);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
+ }
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
- DeleteRegKey(_T("Media Type\\") + null, subtype);
+ DeleteRegKey(_T("Media Type\\") + null, subtype);
- va_list marker;
- va_start(marker, ext);
- for (; ext; ext = va_arg(marker, LPCTSTR)) {
- DeleteRegKey(_T("Media Type\\Extensions"), ext);
- }
- va_end(marker);
+ va_list marker;
+ va_start(marker, ext);
+ for (; ext; ext = va_arg(marker, LPCTSTR)) {
+ DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ }
+ va_end(marker);
}
void UnRegisterSourceFilter(const GUID& subtype)
{
- DeleteRegKey(_T("Media Type\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype));
+ DeleteRegKey(_T("Media Type\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype));
}
typedef struct {
- const GUID* Guid;
- const LPCTSTR Description;
+ const GUID* Guid;
+ const LPCTSTR Description;
} DXVA2_DECODER;
static const DXVA2_DECODER DXVA2Decoder[] = {
- {&GUID_NULL, _T("Unknown")},
- {&GUID_NULL, _T("Not using DXVA")},
- {&DXVA_Intel_H264_ClearVideo, _T("H.264 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo H264 bitstream decoder
- {&DXVA_Intel_VC1_ClearVideo, _T("VC-1 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo VC-1 bitstream decoder
- {&DXVA_MPEG4_ASP, _T("MPEG-4 ASP bitstream decoder")}, // Nvidia MPEG-4 ASP bitstream decoder
- {&DXVA_ModeNone, _T("Mode none")},
- {&DXVA_ModeH261_A, _T("H.261 A, post processing")},
- {&DXVA_ModeH261_B, _T("H.261 B, deblocking")},
- {&DXVA_ModeH263_A, _T("H.263 A, motion compensation, no FGT")},
- {&DXVA_ModeH263_B, _T("H.263 B, motion compensation, FGT")},
- {&DXVA_ModeH263_C, _T("H.263 C, IDCT, no FGT")},
- {&DXVA_ModeH263_D, _T("H.263 D, IDCT, FGT")},
- {&DXVA_ModeH263_E, _T("H.263 E, bitstream decoder, no FGT")},
- {&DXVA_ModeH263_F, _T("H.263 F, bitstream decoder, FGT")},
- {&DXVA_ModeMPEG1_A, _T("MPEG-1 A, post processing")},
- {&DXVA_ModeMPEG2_A, _T("MPEG-2 A, motion compensation")},
- {&DXVA_ModeMPEG2_B, _T("MPEG-2 B, motion compensation + blending")},
- {&DXVA_ModeMPEG2_C, _T("MPEG-2 C, IDCT")},
- {&DXVA_ModeMPEG2_D, _T("MPEG-2 D, IDCT + blending")},
- {&DXVA_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
- {&DXVA_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
- {&DXVA_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
- {&DXVA_ModeH264_D, _T("H.264 D, IDCT, FGT")},
- {&DXVA_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
- {&DXVA_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
- {&DXVA_ModeWMV8_A, _T("WMV8 A, post processing")},
- {&DXVA_ModeWMV8_B, _T("WMV8 B, motion compensation")},
- {&DXVA_ModeWMV9_A, _T("WMV9 A, post processing")},
- {&DXVA_ModeWMV9_B, _T("WMV9 B, motion compensation")},
- {&DXVA_ModeWMV9_C, _T("WMV9 C, IDCT")},
- {&DXVA_ModeVC1_A, _T("VC-1 A, post processing")},
- {&DXVA_ModeVC1_B, _T("VC-1 B, motion compensation")},
- {&DXVA_ModeVC1_C, _T("VC-1 C, IDCT")},
- {&DXVA_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
- {&DXVA_NoEncrypt, _T("No encryption")},
- {&DXVA2_ModeMPEG2_MoComp, _T("MPEG-2 motion compensation")},
- {&DXVA2_ModeMPEG2_IDCT, _T("MPEG-2 IDCT")},
- {&DXVA2_ModeMPEG2_VLD, _T("MPEG-2 variable-length decoder")},
- {&DXVA2_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
- {&DXVA2_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
- {&DXVA2_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
- {&DXVA2_ModeH264_D, _T("H.264 D, IDCT, FGT")},
- {&DXVA2_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
- {&DXVA2_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
- {&DXVA2_ModeWMV8_A, _T("WMV8 A, post processing")},
- {&DXVA2_ModeWMV8_B, _T("WMV8 B, motion compensation")},
- {&DXVA2_ModeWMV9_A, _T("WMV9 A, post processing")},
- {&DXVA2_ModeWMV9_B, _T("WMV9 B, motion compensation")},
- {&DXVA2_ModeWMV9_C, _T("WMV9 C, IDCT")},
- {&DXVA2_ModeVC1_A, _T("VC-1 A, post processing")},
- {&DXVA2_ModeVC1_B, _T("VC-1 B, motion compensation")},
- {&DXVA2_ModeVC1_C, _T("VC-1 C, IDCT")},
- {&DXVA2_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
- {&DXVA2_NoEncrypt, _T("No encryption")},
- {&DXVA2_VideoProcProgressiveDevice, _T("Progressive scan")},
- {&DXVA2_VideoProcBobDevice, _T("Bob deinterlacing")},
- {&DXVA2_VideoProcSoftwareDevice, _T("Software processing")}
+ {&GUID_NULL, _T("Unknown")},
+ {&GUID_NULL, _T("Not using DXVA")},
+ {&DXVA_Intel_H264_ClearVideo, _T("H.264 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo H264 bitstream decoder
+ {&DXVA_Intel_VC1_ClearVideo, _T("VC-1 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo VC-1 bitstream decoder
+ {&DXVA_MPEG4_ASP, _T("MPEG-4 ASP bitstream decoder")}, // Nvidia MPEG-4 ASP bitstream decoder
+ {&DXVA_ModeNone, _T("Mode none")},
+ {&DXVA_ModeH261_A, _T("H.261 A, post processing")},
+ {&DXVA_ModeH261_B, _T("H.261 B, deblocking")},
+ {&DXVA_ModeH263_A, _T("H.263 A, motion compensation, no FGT")},
+ {&DXVA_ModeH263_B, _T("H.263 B, motion compensation, FGT")},
+ {&DXVA_ModeH263_C, _T("H.263 C, IDCT, no FGT")},
+ {&DXVA_ModeH263_D, _T("H.263 D, IDCT, FGT")},
+ {&DXVA_ModeH263_E, _T("H.263 E, bitstream decoder, no FGT")},
+ {&DXVA_ModeH263_F, _T("H.263 F, bitstream decoder, FGT")},
+ {&DXVA_ModeMPEG1_A, _T("MPEG-1 A, post processing")},
+ {&DXVA_ModeMPEG2_A, _T("MPEG-2 A, motion compensation")},
+ {&DXVA_ModeMPEG2_B, _T("MPEG-2 B, motion compensation + blending")},
+ {&DXVA_ModeMPEG2_C, _T("MPEG-2 C, IDCT")},
+ {&DXVA_ModeMPEG2_D, _T("MPEG-2 D, IDCT + blending")},
+ {&DXVA_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
+ {&DXVA_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
+ {&DXVA_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
+ {&DXVA_ModeH264_D, _T("H.264 D, IDCT, FGT")},
+ {&DXVA_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
+ {&DXVA_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
+ {&DXVA_ModeWMV8_A, _T("WMV8 A, post processing")},
+ {&DXVA_ModeWMV8_B, _T("WMV8 B, motion compensation")},
+ {&DXVA_ModeWMV9_A, _T("WMV9 A, post processing")},
+ {&DXVA_ModeWMV9_B, _T("WMV9 B, motion compensation")},
+ {&DXVA_ModeWMV9_C, _T("WMV9 C, IDCT")},
+ {&DXVA_ModeVC1_A, _T("VC-1 A, post processing")},
+ {&DXVA_ModeVC1_B, _T("VC-1 B, motion compensation")},
+ {&DXVA_ModeVC1_C, _T("VC-1 C, IDCT")},
+ {&DXVA_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
+ {&DXVA_NoEncrypt, _T("No encryption")},
+ {&DXVA2_ModeMPEG2_MoComp, _T("MPEG-2 motion compensation")},
+ {&DXVA2_ModeMPEG2_IDCT, _T("MPEG-2 IDCT")},
+ {&DXVA2_ModeMPEG2_VLD, _T("MPEG-2 variable-length decoder")},
+ {&DXVA2_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
+ {&DXVA2_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
+ {&DXVA2_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
+ {&DXVA2_ModeH264_D, _T("H.264 D, IDCT, FGT")},
+ {&DXVA2_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
+ {&DXVA2_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
+ {&DXVA2_ModeWMV8_A, _T("WMV8 A, post processing")},
+ {&DXVA2_ModeWMV8_B, _T("WMV8 B, motion compensation")},
+ {&DXVA2_ModeWMV9_A, _T("WMV9 A, post processing")},
+ {&DXVA2_ModeWMV9_B, _T("WMV9 B, motion compensation")},
+ {&DXVA2_ModeWMV9_C, _T("WMV9 C, IDCT")},
+ {&DXVA2_ModeVC1_A, _T("VC-1 A, post processing")},
+ {&DXVA2_ModeVC1_B, _T("VC-1 B, motion compensation")},
+ {&DXVA2_ModeVC1_C, _T("VC-1 C, IDCT")},
+ {&DXVA2_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
+ {&DXVA2_NoEncrypt, _T("No encryption")},
+ {&DXVA2_VideoProcProgressiveDevice, _T("Progressive scan")},
+ {&DXVA2_VideoProcBobDevice, _T("Bob deinterlacing")},
+ {&DXVA2_VideoProcSoftwareDevice, _T("Software processing")}
};
LPCTSTR GetDXVAMode(const GUID* guidDecoder)
{
- int nPos = 0;
+ int nPos = 0;
- for (int i=1; i<_countof(DXVA2Decoder); i++) {
- if (*guidDecoder == *DXVA2Decoder[i].Guid) {
- nPos = i;
- break;
- }
- }
+ for (int i = 1; i < _countof(DXVA2Decoder); i++) {
+ if (*guidDecoder == *DXVA2Decoder[i].Guid) {
+ nPos = i;
+ break;
+ }
+ }
- return DXVA2Decoder[nPos].Description;
+ return DXVA2Decoder[nPos].Description;
}
void DumpBuffer(BYTE* pBuffer, int nSize)
{
- CString strMsg;
- int nPos = 0;
- strMsg.AppendFormat (L"Size : %d\n", nSize);
- for (int i=0; i<3; i++) {
- for (int j=0; j<32; j++) {
- nPos = i*32 + j;
- if (nPos >= nSize) {
- break;
- }
- strMsg.AppendFormat (L"%02x ", pBuffer[nPos]);
- }
- if (nPos >= nSize) {
- break;
- }
- strMsg.Append(L"\n");
- }
-
- if (nSize > 32*3) {
- strMsg.Append(L".../...\n");
- for (int j=32; j>0; j--) {
- strMsg.AppendFormat (L"%02x ", pBuffer[nSize - j]);
- }
- }
- strMsg.AppendFormat(L"\n");
-
- TRACE (strMsg);
+ CString strMsg;
+ int nPos = 0;
+ strMsg.AppendFormat(L"Size : %d\n", nSize);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 32; j++) {
+ nPos = i * 32 + j;
+ if (nPos >= nSize) {
+ break;
+ }
+ strMsg.AppendFormat(L"%02x ", pBuffer[nPos]);
+ }
+ if (nPos >= nSize) {
+ break;
+ }
+ strMsg.Append(L"\n");
+ }
+
+ if (nSize > 32 * 3) {
+ strMsg.Append(L".../...\n");
+ for (int j = 32; j > 0; j--) {
+ strMsg.AppendFormat(L"%02x ", pBuffer[nSize - j]);
+ }
+ }
+ strMsg.AppendFormat(L"\n");
+
+ TRACE(strMsg);
}
// hour, minute, second, millisec
CString ReftimeToString(const REFERENCE_TIME& rtVal)
{
- CString strTemp;
- LONGLONG llTotalMs = ConvertToMilliseconds (rtVal);
- int lHour = (int)(llTotalMs / (1000*60*60));
- int lMinute = (llTotalMs / (1000*60)) % 60;
- int lSecond = (llTotalMs / 1000) % 60;
- int lMillisec = llTotalMs % 1000;
+ CString strTemp;
+ LONGLONG llTotalMs = ConvertToMilliseconds(rtVal);
+ int lHour = (int)(llTotalMs / (1000 * 60 * 60));
+ int lMinute = (llTotalMs / (1000 * 60)) % 60;
+ int lSecond = (llTotalMs / 1000) % 60;
+ int lMillisec = llTotalMs % 1000;
- strTemp.Format (_T("%02d:%02d:%02d,%03d"), lHour, lMinute, lSecond, lMillisec);
- return strTemp;
+ strTemp.Format(_T("%02d:%02d:%02d,%03d"), lHour, lMinute, lSecond, lMillisec);
+ return strTemp;
}
// hour, minute, second (round)
CString ReftimeToString2(const REFERENCE_TIME& rtVal)
{
- CString strTemp;
- LONGLONG seconds = (rtVal + 5000000) / 10000000;
- int lHour = (int)(seconds / 3600);
- int lMinute = (int)(seconds / 60 % 60);
- int lSecond = (int)(seconds % 60);
+ CString strTemp;
+ LONGLONG seconds = (rtVal + 5000000) / 10000000;
+ int lHour = (int)(seconds / 3600);
+ int lMinute = (int)(seconds / 60 % 60);
+ int lSecond = (int)(seconds % 60);
- strTemp.Format (_T("%02d:%02d:%02d"), lHour, lMinute, lSecond);
- return strTemp;
+ strTemp.Format(_T("%02d:%02d:%02d"), lHour, lMinute, lSecond);
+ return strTemp;
}
CString DVDtimeToString(const DVD_HMSF_TIMECODE& rtVal, bool bAlwaysShowHours)
{
- CString strTemp;
- if (rtVal.bHours > 0 || bAlwaysShowHours) {
- strTemp.Format(_T("%02d:%02d:%02d"), rtVal.bHours, rtVal.bMinutes, rtVal.bSeconds);
- } else {
- strTemp.Format(_T("%02d:%02d"), rtVal.bMinutes, rtVal.bSeconds);
- }
- return strTemp;
+ CString strTemp;
+ if (rtVal.bHours > 0 || bAlwaysShowHours) {
+ strTemp.Format(_T("%02d:%02d:%02d"), rtVal.bHours, rtVal.bMinutes, rtVal.bSeconds);
+ } else {
+ strTemp.Format(_T("%02d:%02d"), rtVal.bMinutes, rtVal.bSeconds);
+ }
+ return strTemp;
}
REFERENCE_TIME StringToReftime(LPCTSTR strVal)
{
- REFERENCE_TIME rt = 0;
- int lHour = 0;
- int lMinute = 0;
- int lSecond = 0;
- int lMillisec = 0;
+ REFERENCE_TIME rt = 0;
+ int lHour = 0;
+ int lMinute = 0;
+ int lSecond = 0;
+ int lMillisec = 0;
- if (_stscanf_s (strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4) {
- rt = ( (((lHour*24)+lMinute)*60 + lSecond) * MILLISECONDS + lMillisec ) * (UNITS/MILLISECONDS);
- }
+ if (_stscanf_s(strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4) {
+ rt = ((((lHour * 24) + lMinute) * 60 + lSecond) * MILLISECONDS + lMillisec) * (UNITS / MILLISECONDS);
+ }
- return rt;
+ return rt;
}
const double Rec601_Kr = 0.299;
@@ -2634,21 +2617,21 @@ const double Rec601_Kg = 0.587;
COLORREF YCrCbToRGB_Rec601(BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec601_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec601_Kb)*Rec601_Kb/Rec601_Kg - 2*(Cr-128)*(1.0-Rec601_Kr)*Rec601_Kr/Rec601_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec601_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec601_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - 2 * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec601_Kb);
- return RGB (fabs(rp), fabs(gp), fabs(bp));
+ return RGB(fabs(rp), fabs(gp), fabs(bp));
}
DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec601_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec601_Kb)*Rec601_Kb/Rec601_Kg - 2*(Cr-128)*(1.0-Rec601_Kr)*Rec601_Kr/Rec601_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec601_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec601_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - 2 * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec601_Kb);
- return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
+ return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
}
@@ -2659,319 +2642,326 @@ const double Rec709_Kg = 0.7154;
COLORREF YCrCbToRGB_Rec709(BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec709_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec709_Kb)*Rec709_Kb/Rec709_Kg - 2*(Cr-128)*(1.0-Rec709_Kr)*Rec709_Kr/Rec709_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec709_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec709_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - 2 * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec709_Kb);
- return RGB (fabs(rp), fabs(gp), fabs(bp));
+ return RGB(fabs(rp), fabs(gp), fabs(bp));
}
DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec709_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec709_Kb)*Rec709_Kb/Rec709_Kg - 2*(Cr-128)*(1.0-Rec709_Kr)*Rec709_Kr/Rec709_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec709_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec709_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - 2 * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec709_Kb);
- return D3DCOLOR_ARGB (A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
+ return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
}
void TraceFilterInfo(IBaseFilter* pBF)
{
- FILTER_INFO Info;
- if (SUCCEEDED (pBF->QueryFilterInfo(&Info))) {
- TRACE (" === Filter info : %S\n", Info.achName);
- BeginEnumPins(pBF, pEnum, pPin) {
- TracePinInfo(pPin);
- }
+ FILTER_INFO Info;
+ if (SUCCEEDED(pBF->QueryFilterInfo(&Info))) {
+ TRACE(" === Filter info : %S\n", Info.achName);
+ BeginEnumPins(pBF, pEnum, pPin) {
+ TracePinInfo(pPin);
+ }
- EndEnumPins
- Info.pGraph->Release();
- }
+ EndEnumPins
+ Info.pGraph->Release();
+ }
}
void TracePinInfo(IPin* pPin)
{
- PIN_INFO PinInfo;
- FILTER_INFO ConnectedFilterInfo;
- PIN_INFO ConnectedInfo;
- CComPtr<IPin> pConnected;
- memset (&ConnectedInfo, 0, sizeof(ConnectedInfo));
- memset (&ConnectedFilterInfo, 0, sizeof(ConnectedFilterInfo));
- if (SUCCEEDED (pPin->ConnectedTo (&pConnected))) {
- pConnected->QueryPinInfo (&ConnectedInfo);
- ConnectedInfo.pFilter->QueryFilterInfo(&ConnectedFilterInfo);
- ConnectedInfo.pFilter->Release();
- ConnectedFilterInfo.pGraph->Release();
- }
- pPin->QueryPinInfo (&PinInfo);
- TRACE(" %S (%S) -> %S (Filter %S)\n",
- PinInfo.achName,
- PinInfo.dir == PINDIR_OUTPUT ? _T("Out") : _T("In"),
- ConnectedInfo.achName,
- ConnectedFilterInfo.achName);
- PinInfo.pFilter->Release();
-}
-
-const wchar_t *StreamTypeToName(PES_STREAM_TYPE _Type)
-{
- switch (_Type) {
- case VIDEO_STREAM_MPEG1:
- return L"MPEG-1";
- case VIDEO_STREAM_MPEG2:
- return L"MPEG-2";
- case AUDIO_STREAM_MPEG1:
- return L"MPEG-1";
- case AUDIO_STREAM_MPEG2:
- return L"MPEG-2";
- case VIDEO_STREAM_H264:
- return L"H264";
- case AUDIO_STREAM_LPCM:
- return L"LPCM";
- case AUDIO_STREAM_AC3:
- return L"Dolby Digital";
- case AUDIO_STREAM_DTS:
- return L"DTS";
- case AUDIO_STREAM_AC3_TRUE_HD:
- return L"Dolby TrueHD";
- case AUDIO_STREAM_AC3_PLUS:
- return L"Dolby Digital Plus";
- case AUDIO_STREAM_DTS_HD:
- return L"DTS-HD High Resolution Audio";
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- return L"DTS-HD Master Audio";
- case PRESENTATION_GRAPHICS_STREAM:
- return L"Presentation Graphics Stream";
- case INTERACTIVE_GRAPHICS_STREAM:
- return L"Interactive Graphics Stream";
- case SUBTITLE_STREAM:
- return L"Subtitle";
- case SECONDARY_AUDIO_AC3_PLUS:
- return L"Secondary Dolby Digital Plus";
- case SECONDARY_AUDIO_DTS_HD:
- return L"Secondary DTS-HD High Resolution Audio";
- case VIDEO_STREAM_VC1:
- return L"VC-1";
- }
- return NULL;
+ PIN_INFO PinInfo;
+ FILTER_INFO ConnectedFilterInfo;
+ PIN_INFO ConnectedInfo;
+ CComPtr<IPin> pConnected;
+ memset(&ConnectedInfo, 0, sizeof(ConnectedInfo));
+ memset(&ConnectedFilterInfo, 0, sizeof(ConnectedFilterInfo));
+ if (SUCCEEDED(pPin->ConnectedTo(&pConnected))) {
+ pConnected->QueryPinInfo(&ConnectedInfo);
+ ConnectedInfo.pFilter->QueryFilterInfo(&ConnectedFilterInfo);
+ ConnectedInfo.pFilter->Release();
+ ConnectedFilterInfo.pGraph->Release();
+ }
+ pPin->QueryPinInfo(&PinInfo);
+ TRACE(" %S (%S) -> %S (Filter %S)\n",
+ PinInfo.achName,
+ PinInfo.dir == PINDIR_OUTPUT ? _T("Out") : _T("In"),
+ ConnectedInfo.achName,
+ ConnectedFilterInfo.achName);
+ PinInfo.pFilter->Release();
+}
+
+const wchar_t* StreamTypeToName(PES_STREAM_TYPE _Type)
+{
+ switch (_Type) {
+ case VIDEO_STREAM_MPEG1:
+ return L"MPEG-1";
+ case VIDEO_STREAM_MPEG2:
+ return L"MPEG-2";
+ case AUDIO_STREAM_MPEG1:
+ return L"MPEG-1";
+ case AUDIO_STREAM_MPEG2:
+ return L"MPEG-2";
+ case VIDEO_STREAM_H264:
+ return L"H264";
+ case AUDIO_STREAM_LPCM:
+ return L"LPCM";
+ case AUDIO_STREAM_AC3:
+ return L"Dolby Digital";
+ case AUDIO_STREAM_DTS:
+ return L"DTS";
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ return L"Dolby TrueHD";
+ case AUDIO_STREAM_AC3_PLUS:
+ return L"Dolby Digital Plus";
+ case AUDIO_STREAM_DTS_HD:
+ return L"DTS-HD High Resolution Audio";
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ return L"DTS-HD Master Audio";
+ case PRESENTATION_GRAPHICS_STREAM:
+ return L"Presentation Graphics Stream";
+ case INTERACTIVE_GRAPHICS_STREAM:
+ return L"Interactive Graphics Stream";
+ case SUBTITLE_STREAM:
+ return L"Subtitle";
+ case SECONDARY_AUDIO_AC3_PLUS:
+ return L"Secondary Dolby Digital Plus";
+ case SECONDARY_AUDIO_DTS_HD:
+ return L"Secondary DTS-HD High Resolution Audio";
+ case VIDEO_STREAM_VC1:
+ return L"VC-1";
+ }
+ return NULL;
}
//
// Usage: SetThreadName (-1, "MainThread");
//
typedef struct tagTHREADNAME_INFO {
- DWORD dwType; // must be 0x1000
- LPCSTR szName; // pointer to name (in user addr space)
- DWORD dwThreadID; // thread ID (-1 caller thread)
- DWORD dwFlags; // reserved for future use, must be zero
+ DWORD dwType; // must be 0x1000
+ LPCSTR szName; // pointer to name (in user addr space)
+ DWORD dwThreadID; // thread ID (-1 caller thread)
+ DWORD dwFlags; // reserved for future use, must be zero
} THREADNAME_INFO;
void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName)
{
- THREADNAME_INFO info;
- info.dwType = 0x1000;
- info.szName = szThreadName;
- info.dwThreadID = dwThreadID;
- info.dwFlags = 0;
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = szThreadName;
+ info.dwThreadID = dwThreadID;
+ info.dwFlags = 0;
- __try {
- RaiseException(0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR*)&info);
- }
- __except (EXCEPTION_CONTINUE_EXECUTION) {
- }
+ __try {
+ RaiseException(0x406D1388, 0, sizeof(info) / sizeof(DWORD), (ULONG_PTR*)&info);
+ } __except (EXCEPTION_CONTINUE_EXECUTION) {
+ }
}
void HexDump(CString fileName, BYTE* buf, int size)
{
- if (size<=0) {
- return;
- }
-
- CString dump_str;
- dump_str.Format(_T("Dump size = %d\n"), size);
- int len, i, j, c;
-
- for (i=0; i<size; i+=16) {
- len = size - i;
- if (len > 16) {
- len = 16;
- }
- dump_str.AppendFormat(_T("%08x "), i);
- for (j=0; j<16; j++) {
- if (j < len) {
- dump_str.AppendFormat(_T(" %02x"), buf[i+j]);
- }
- else {
- dump_str.Append(_T(" "));
- }
- }
- dump_str.Append(_T(" "));
- for (j=0; j<len; j++) {
- c = buf[i+j];
- if (c < ' ' || c > '~') {
- c = '.';
- }
- dump_str.AppendFormat(_T("%c"), c);
- }
- dump_str.Append(_T("\n"));
- }
- dump_str.Append(_T("\n"));
-
- if (!fileName.IsEmpty()) {
- CStdioFile file;
- if (file.Open(fileName, CFile::modeCreate|CFile::modeWrite)) {
- file.WriteString(dump_str);
- file.Close();
- }
- }
- else {
- TRACE(dump_str);
- }
+ if (size <= 0) {
+ return;
+ }
+
+ CString dump_str;
+ dump_str.Format(_T("Dump size = %d\n"), size);
+ int len, i, j, c;
+
+ for (i = 0; i < size; i += 16) {
+ len = size - i;
+ if (len > 16) {
+ len = 16;
+ }
+ dump_str.AppendFormat(_T("%08x "), i);
+ for (j = 0; j < 16; j++) {
+ if (j < len) {
+ dump_str.AppendFormat(_T(" %02x"), buf[i + j]);
+ } else {
+ dump_str.Append(_T(" "));
+ }
+ }
+ dump_str.Append(_T(" "));
+ for (j = 0; j < len; j++) {
+ c = buf[i + j];
+ if (c < ' ' || c > '~') {
+ c = '.';
+ }
+ dump_str.AppendFormat(_T("%c"), c);
+ }
+ dump_str.Append(_T("\n"));
+ }
+ dump_str.Append(_T("\n"));
+
+ if (!fileName.IsEmpty()) {
+ CStdioFile file;
+ if (file.Open(fileName, CFile::modeCreate | CFile::modeWrite)) {
+ file.WriteString(dump_str);
+ file.Close();
+ }
+ } else {
+ TRACE(dump_str);
+ }
}
void CorrectComboListWidth(CComboBox& m_pComboBox)
{
- // Find the longest string in the combo box.
- if (m_pComboBox.GetCount() <=0 )
- return;
-
- CString str;
- CSize sz;
- int dx = 0;
- TEXTMETRIC tm;
- CDC* pDC = m_pComboBox.GetDC();
- CFont* pFont = m_pComboBox.GetFont();
-
- // Select the listbox font, save the old font
- CFont* pOldFont = pDC->SelectObject(pFont);
- // Get the text metrics for avg char width
- pDC->GetTextMetrics(&tm);
-
- for (int i = 0; i < m_pComboBox.GetCount(); i++)
- {
- m_pComboBox.GetLBText(i, str);
- sz = pDC->GetTextExtent(str);
-
- // Add the avg width to prevent clipping
- sz.cx += tm.tmAveCharWidth;
-
- if (sz.cx > dx)
- dx = sz.cx;
- }
- // Select the old font back into the DC
- pDC->SelectObject(pOldFont);
- m_pComboBox.ReleaseDC(pDC);
-
- // Get the scrollbar width if it exists
- int min_visible = m_pComboBox.GetMinVisible();
- int scroll_width = (m_pComboBox.GetCount() > min_visible) ?
- ::GetSystemMetrics(SM_CXVSCROLL) : 0;
-
- // Adjust the width for the vertical scroll bar and the left and right border.
- dx += scroll_width + 2*::GetSystemMetrics(SM_CXEDGE);
-
- // Set the width of the list box so that every item is completely visible.
- m_pComboBox.SetDroppedWidth(dx);
-}
-
-unsigned int lav_xiphlacing(unsigned char *s, unsigned int v)
-{
- unsigned int n = 0;
-
- while (v >= 0xff) {
- *s++ = 0xff;
- v -= 0xff;
- n++;
- }
- *s = v;
- n++;
- return n;
-}
-
-void getExtraData(const BYTE *format, const GUID *formattype, const size_t formatlen, BYTE *extra, unsigned int *extralen)
-{
- // code from LAV ...
- const BYTE *extraposition = NULL;
- size_t extralength = 0;
- if (*formattype == FORMAT_WaveFormatEx) {
- //WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
- extraposition = format + sizeof(WAVEFORMATEX);
- // Protected against over-reads
- extralength = formatlen - sizeof(WAVEFORMATEX);
- } else if (*formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
- unsigned offset = 1;
- if (extra) {
- *extra = 2;
- offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[0]);
- offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[1]);
- extra += offset;
- } else {
- BYTE dummy[100];
- offset += lav_xiphlacing(dummy, vf2->HeaderSize[0]);
- offset += lav_xiphlacing(dummy, vf2->HeaderSize[1]);
- }
- extralength = vf2->HeaderSize[0] + vf2->HeaderSize[1] + vf2->HeaderSize[2];
- extralength = min(extralength, formatlen - sizeof(VORBISFORMAT2));
-
- if (extra && extralength)
- memcpy(extra, format + sizeof(VORBISFORMAT2), extralength);
- if (extralen)
- *extralen = (unsigned int)extralength + offset;
-
- return;
- } else if (*formattype == FORMAT_VideoInfo) {
- extraposition = format + sizeof(VIDEOINFOHEADER);
- extralength = formatlen - sizeof(VIDEOINFOHEADER);
- } else if (*formattype == FORMAT_VideoInfo2) {
- extraposition = format + sizeof(VIDEOINFOHEADER2);
- extralength = formatlen - sizeof(VIDEOINFOHEADER2);
- } else if (*formattype == FORMAT_MPEGVideo) {
- MPEG1VIDEOINFO *mp1vi = (MPEG1VIDEOINFO *)format;
- extraposition = (BYTE *)mp1vi->bSequenceHeader;
- extralength = min(mp1vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader[0]));
- } else if (*formattype == FORMAT_MPEG2Video) {
- MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)format;
- extraposition = (BYTE *)mp2vi->dwSequenceHeader;
- extralength = min(mp2vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader[0]));
- }
-
- if (extra && extralength)
- memcpy(extra, extraposition, extralength);
- if (extralen)
- *extralen = (unsigned int)extralength;
-}
-
-void audioFormatTypeHandler(const BYTE *format, const GUID *formattype, DWORD *pnSamples, WORD *pnChannels, WORD *pnBitsPerSample, WORD *pnBlockAlign, DWORD *pnBytesPerSec)
-{
- DWORD nSamples = 0;
- WORD nChannels = 0;
- WORD nBitsPerSample = 0;
- WORD nBlockAlign = 0;
- DWORD nBytesPerSec = 0;
-
- if (*formattype == FORMAT_WaveFormatEx) {
- WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
- nSamples = wfex->nSamplesPerSec;
- nChannels = wfex->nChannels;
- nBitsPerSample = wfex->wBitsPerSample;
- nBlockAlign = wfex->nBlockAlign;
- nBytesPerSec = wfex->nAvgBytesPerSec;
- } else if (*formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
- nSamples = vf2->SamplesPerSec;
- nChannels = (WORD)vf2->Channels;
- nBitsPerSample = (WORD)vf2->BitsPerSample;
- }
-
- if (pnSamples)
- *pnSamples = nSamples;
- if (pnChannels)
- *pnChannels = nChannels;
- if (pnBitsPerSample)
- *pnBitsPerSample = nBitsPerSample;
- if (pnBlockAlign)
- *pnBlockAlign = nBlockAlign;
- if (pnBytesPerSec)
- *pnBytesPerSec = nBytesPerSec;
+ // Find the longest string in the combo box.
+ if (m_pComboBox.GetCount() <= 0) {
+ return;
+ }
+
+ CString str;
+ CSize sz;
+ int dx = 0;
+ TEXTMETRIC tm;
+ CDC* pDC = m_pComboBox.GetDC();
+ CFont* pFont = m_pComboBox.GetFont();
+
+ // Select the listbox font, save the old font
+ CFont* pOldFont = pDC->SelectObject(pFont);
+ // Get the text metrics for avg char width
+ pDC->GetTextMetrics(&tm);
+
+ for (int i = 0; i < m_pComboBox.GetCount(); i++) {
+ m_pComboBox.GetLBText(i, str);
+ sz = pDC->GetTextExtent(str);
+
+ // Add the avg width to prevent clipping
+ sz.cx += tm.tmAveCharWidth;
+
+ if (sz.cx > dx) {
+ dx = sz.cx;
+ }
+ }
+ // Select the old font back into the DC
+ pDC->SelectObject(pOldFont);
+ m_pComboBox.ReleaseDC(pDC);
+
+ // Get the scrollbar width if it exists
+ int min_visible = m_pComboBox.GetMinVisible();
+ int scroll_width = (m_pComboBox.GetCount() > min_visible) ?
+ ::GetSystemMetrics(SM_CXVSCROLL) : 0;
+
+ // Adjust the width for the vertical scroll bar and the left and right border.
+ dx += scroll_width + 2 *::GetSystemMetrics(SM_CXEDGE);
+
+ // Set the width of the list box so that every item is completely visible.
+ m_pComboBox.SetDroppedWidth(dx);
+}
+
+unsigned int lav_xiphlacing(unsigned char* s, unsigned int v)
+{
+ unsigned int n = 0;
+
+ while (v >= 0xff) {
+ *s++ = 0xff;
+ v -= 0xff;
+ n++;
+ }
+ *s = v;
+ n++;
+ return n;
+}
+
+void getExtraData(const BYTE* format, const GUID* formattype, const size_t formatlen, BYTE* extra, unsigned int* extralen)
+{
+ // code from LAV ...
+ const BYTE* extraposition = NULL;
+ size_t extralength = 0;
+ if (*formattype == FORMAT_WaveFormatEx) {
+ //WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
+ extraposition = format + sizeof(WAVEFORMATEX);
+ // Protected against over-reads
+ extralength = formatlen - sizeof(WAVEFORMATEX);
+ } else if (*formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2* vf2 = (VORBISFORMAT2*)format;
+ unsigned offset = 1;
+ if (extra) {
+ *extra = 2;
+ offset += lav_xiphlacing(extra + offset, vf2->HeaderSize[0]);
+ offset += lav_xiphlacing(extra + offset, vf2->HeaderSize[1]);
+ extra += offset;
+ } else {
+ BYTE dummy[100];
+ offset += lav_xiphlacing(dummy, vf2->HeaderSize[0]);
+ offset += lav_xiphlacing(dummy, vf2->HeaderSize[1]);
+ }
+ extralength = vf2->HeaderSize[0] + vf2->HeaderSize[1] + vf2->HeaderSize[2];
+ extralength = min(extralength, formatlen - sizeof(VORBISFORMAT2));
+
+ if (extra && extralength) {
+ memcpy(extra, format + sizeof(VORBISFORMAT2), extralength);
+ }
+ if (extralen) {
+ *extralen = (unsigned int)extralength + offset;
+ }
+
+ return;
+ } else if (*formattype == FORMAT_VideoInfo) {
+ extraposition = format + sizeof(VIDEOINFOHEADER);
+ extralength = formatlen - sizeof(VIDEOINFOHEADER);
+ } else if (*formattype == FORMAT_VideoInfo2) {
+ extraposition = format + sizeof(VIDEOINFOHEADER2);
+ extralength = formatlen - sizeof(VIDEOINFOHEADER2);
+ } else if (*formattype == FORMAT_MPEGVideo) {
+ MPEG1VIDEOINFO* mp1vi = (MPEG1VIDEOINFO*)format;
+ extraposition = (BYTE*)mp1vi->bSequenceHeader;
+ extralength = min(mp1vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader[0]));
+ } else if (*formattype == FORMAT_MPEG2Video) {
+ MPEG2VIDEOINFO* mp2vi = (MPEG2VIDEOINFO*)format;
+ extraposition = (BYTE*)mp2vi->dwSequenceHeader;
+ extralength = min(mp2vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader[0]));
+ }
+
+ if (extra && extralength) {
+ memcpy(extra, extraposition, extralength);
+ }
+ if (extralen) {
+ *extralen = (unsigned int)extralength;
+ }
+}
+
+void audioFormatTypeHandler(const BYTE* format, const GUID* formattype, DWORD* pnSamples, WORD* pnChannels, WORD* pnBitsPerSample, WORD* pnBlockAlign, DWORD* pnBytesPerSec)
+{
+ DWORD nSamples = 0;
+ WORD nChannels = 0;
+ WORD nBitsPerSample = 0;
+ WORD nBlockAlign = 0;
+ DWORD nBytesPerSec = 0;
+
+ if (*formattype == FORMAT_WaveFormatEx) {
+ WAVEFORMATEX* wfex = (WAVEFORMATEX*)format;
+ nSamples = wfex->nSamplesPerSec;
+ nChannels = wfex->nChannels;
+ nBitsPerSample = wfex->wBitsPerSample;
+ nBlockAlign = wfex->nBlockAlign;
+ nBytesPerSec = wfex->nAvgBytesPerSec;
+ } else if (*formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2* vf2 = (VORBISFORMAT2*)format;
+ nSamples = vf2->SamplesPerSec;
+ nChannels = (WORD)vf2->Channels;
+ nBitsPerSample = (WORD)vf2->BitsPerSample;
+ }
+
+ if (pnSamples) {
+ *pnSamples = nSamples;
+ }
+ if (pnChannels) {
+ *pnChannels = nChannels;
+ }
+ if (pnBitsPerSample) {
+ *pnBitsPerSample = nBitsPerSample;
+ }
+ if (pnBlockAlign) {
+ *pnBlockAlign = nBlockAlign;
+ }
+ if (pnBytesPerSec) {
+ *pnBytesPerSec = nBytesPerSec;
+ }
}
diff --git a/src/DSUtil/DSUtil.h b/src/DSUtil/DSUtil.h
index 5a9caef3d..2b6dc26ea 100644
--- a/src/DSUtil/DSUtil.h
+++ b/src/DSUtil/DSUtil.h
@@ -116,40 +116,40 @@ extern LPCTSTR GetDXVAMode(const GUID* guidDecoder);
extern void DumpBuffer(BYTE* pBuffer, int nSize);
extern CString ReftimeToString(const REFERENCE_TIME& rtVal);
extern CString ReftimeToString2(const REFERENCE_TIME& rtVal);
-extern CString DVDtimeToString(const DVD_HMSF_TIMECODE& rtVal, bool bAlwaysShowHours=false);
+extern CString DVDtimeToString(const DVD_HMSF_TIMECODE& rtVal, bool bAlwaysShowHours = false);
extern REFERENCE_TIME StringToReftime(LPCTSTR strVal);
extern COLORREF YCrCbToRGB_Rec601(BYTE Y, BYTE Cr, BYTE Cb);
extern COLORREF YCrCbToRGB_Rec709(BYTE Y, BYTE Cr, BYTE Cb);
-extern DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
-extern DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
-extern void TraceFilterInfo(IBaseFilter* pBF);
-extern void TracePinInfo(IPin* pPin);
-extern void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName);
-extern void HexDump(CString fName, BYTE* buf, int size);
-extern void CorrectComboListWidth(CComboBox& m_pComboBox);
+extern DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
+extern DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
+extern void TraceFilterInfo(IBaseFilter* pBF);
+extern void TracePinInfo(IPin* pPin);
+extern void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName);
+extern void HexDump(CString fName, BYTE* buf, int size);
+extern void CorrectComboListWidth(CComboBox& m_pComboBox);
-extern void getExtraData(const BYTE *format, const GUID *formattype, const size_t formatlen, BYTE *extra, unsigned int *extralen);
-extern void audioFormatTypeHandler(const BYTE *format, const GUID *formattype, DWORD *pnSamples, WORD *pnChannels, WORD *pnBitsPerSample, WORD *pnBlockAlign, DWORD *pnBytesPerSec);
+extern void getExtraData(const BYTE* format, const GUID* formattype, const size_t formatlen, BYTE* extra, unsigned int* extralen);
+extern void audioFormatTypeHandler(const BYTE* format, const GUID* formattype, DWORD* pnSamples, WORD* pnChannels, WORD* pnBitsPerSample, WORD* pnBlockAlign, DWORD* pnBytesPerSec);
typedef enum {
- PICT_NONE,
- PICT_TOP_FIELD,
- PICT_BOTTOM_FIELD,
- PICT_FRAME
+ PICT_NONE,
+ PICT_TOP_FIELD,
+ PICT_BOTTOM_FIELD,
+ PICT_FRAME
} FF_FIELD_TYPE;
class CPinInfo : public PIN_INFO
{
public:
- CPinInfo() { pFilter = NULL; }
- ~CPinInfo() { if (pFilter) { pFilter->Release(); } }
+ CPinInfo() { pFilter = NULL; }
+ ~CPinInfo() { if (pFilter) { pFilter->Release(); } }
};
class CFilterInfo : public FILTER_INFO
{
public:
- CFilterInfo() { pGraph = NULL; }
- ~CFilterInfo() { if (pGraph) { pGraph->Release(); } }
+ CFilterInfo() { pGraph = NULL; }
+ ~CFilterInfo() { if (pGraph) { pGraph->Release(); } }
};
#define BeginEnumFilters(pFilterGraph, pEnumFilters, pBaseFilter) \
@@ -206,8 +206,8 @@ public:
template <typename T> __inline void INITDDSTRUCT(T& dd)
{
- ZeroMemory(&dd, sizeof(dd));
- dd.dwSize = sizeof(dd);
+ ZeroMemory(&dd, sizeof(dd));
+ dd.dwSize = sizeof(dd);
}
#ifndef _countof
@@ -217,12 +217,12 @@ template <typename T> __inline void INITDDSTRUCT(T& dd)
template <class T>
static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr)
{
- *phr = S_OK;
- CUnknown* punk = DNew T(lpunk, phr);
- if (punk == NULL) {
- *phr = E_OUTOFMEMORY;
- }
- return punk;
+ *phr = S_OK;
+ CUnknown* punk = DNew T(lpunk, phr);
+ if (punk == NULL) {
+ *phr = E_OUTOFMEMORY;
+ }
+ return punk;
}
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
@@ -231,15 +231,15 @@ static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr)
inline int LNKO(int a, int b)
{
- if (a == 0 || b == 0) {
- return 1;
- }
- while (a != b) {
- if (a < b) {
- b -= a;
- } else if (a > b) {
- a -= b;
- }
- }
- return a;
+ if (a == 0 || b == 0) {
+ return 1;
+ }
+ while (a != b) {
+ if (a < b) {
+ b -= a;
+ } else if (a > b) {
+ a -= b;
+ }
+ }
+ return a;
}
diff --git a/src/DSUtil/FontInstaller.cpp b/src/DSUtil/FontInstaller.cpp
index 64ad859b6..efbe25b23 100644
--- a/src/DSUtil/FontInstaller.cpp
+++ b/src/DSUtil/FontInstaller.cpp
@@ -26,93 +26,93 @@
CFontInstaller::CFontInstaller()
{
- if (HMODULE hGdi = GetModuleHandle(_T("gdi32.dll"))) {
- pAddFontMemResourceEx = (HANDLE (WINAPI *)(PVOID,DWORD,PVOID,DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx");
- pAddFontResourceEx = (int (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "AddFontResourceExW");
- pRemoveFontMemResourceEx = (BOOL (WINAPI *)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
- pRemoveFontResourceEx = (BOOL (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "RemoveFontResourceExW");
- }
-
- if (HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) {
- pMoveFileEx = (BOOL (WINAPI *)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExW");
- }
+ if (HMODULE hGdi = GetModuleHandle(_T("gdi32.dll"))) {
+ pAddFontMemResourceEx = (HANDLE(WINAPI*)(PVOID, DWORD, PVOID, DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx");
+ pAddFontResourceEx = (int (WINAPI*)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "AddFontResourceExW");
+ pRemoveFontMemResourceEx = (BOOL (WINAPI*)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
+ pRemoveFontResourceEx = (BOOL (WINAPI*)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "RemoveFontResourceExW");
+ }
+
+ if (HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) {
+ pMoveFileEx = (BOOL (WINAPI*)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExW");
+ }
}
CFontInstaller::~CFontInstaller()
{
- UninstallFonts();
+ UninstallFonts();
}
bool CFontInstaller::InstallFont(const CAtlArray<BYTE>& data)
{
- return InstallFont(data.GetData(), (UINT)data.GetCount());
+ return InstallFont(data.GetData(), (UINT)data.GetCount());
}
bool CFontInstaller::InstallFont(const void* pData, UINT len)
{
- return InstallFontFile(pData, len) || InstallFontMemory(pData, len);
+ return InstallFontFile(pData, len) || InstallFontMemory(pData, len);
}
void CFontInstaller::UninstallFonts()
{
- if (pRemoveFontMemResourceEx) {
- POSITION pos = m_fonts.GetHeadPosition();
- while (pos) {
- pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
- }
- m_fonts.RemoveAll();
- }
-
- if (pRemoveFontResourceEx) {
- POSITION pos = m_files.GetHeadPosition();
- while (pos) {
- CString fn = m_files.GetNext(pos);
- pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
- if (!DeleteFile(fn) && pMoveFileEx) {
- pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- }
-
- m_files.RemoveAll();
- }
+ if (pRemoveFontMemResourceEx) {
+ POSITION pos = m_fonts.GetHeadPosition();
+ while (pos) {
+ pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
+ }
+ m_fonts.RemoveAll();
+ }
+
+ if (pRemoveFontResourceEx) {
+ POSITION pos = m_files.GetHeadPosition();
+ while (pos) {
+ CString fn = m_files.GetNext(pos);
+ pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
+ if (!DeleteFile(fn) && pMoveFileEx) {
+ pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+ }
+
+ m_files.RemoveAll();
+ }
}
bool CFontInstaller::InstallFontMemory(const void* pData, UINT len)
{
- if (!pAddFontMemResourceEx) {
- return false;
- }
-
- DWORD nFonts = 0;
- HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
- if (hFont && nFonts > 0) {
- m_fonts.AddTail(hFont);
- }
- return hFont && nFonts > 0;
+ if (!pAddFontMemResourceEx) {
+ return false;
+ }
+
+ DWORD nFonts = 0;
+ HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
+ if (hFont && nFonts > 0) {
+ m_fonts.AddTail(hFont);
+ }
+ return hFont && nFonts > 0;
}
bool CFontInstaller::InstallFontFile(const void* pData, UINT len)
{
- if (!pAddFontResourceEx) {
- return false;
- }
-
- CFile f;
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) {
- return false;
- }
-
- if (f.Open(fn, CFile::modeWrite)) {
- f.Write(pData, len);
- f.Close();
-
- if (pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) {
- m_files.AddTail(fn);
- return true;
- }
- }
-
- DeleteFile(fn);
- return false;
+ if (!pAddFontResourceEx) {
+ return false;
+ }
+
+ CFile f;
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) {
+ return false;
+ }
+
+ if (f.Open(fn, CFile::modeWrite)) {
+ f.Write(pData, len);
+ f.Close();
+
+ if (pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) {
+ m_files.AddTail(fn);
+ return true;
+ }
+ }
+
+ DeleteFile(fn);
+ return false;
}
diff --git a/src/DSUtil/FontInstaller.h b/src/DSUtil/FontInstaller.h
index 092317785..1114ed90a 100644
--- a/src/DSUtil/FontInstaller.h
+++ b/src/DSUtil/FontInstaller.h
@@ -27,22 +27,22 @@
class CFontInstaller
{
- HANDLE (WINAPI *pAddFontMemResourceEx)(PVOID,DWORD,PVOID,DWORD*);
- BOOL (WINAPI *pRemoveFontMemResourceEx)(HANDLE);
- int (WINAPI *pAddFontResourceEx)(LPCTSTR,DWORD,PVOID);
- BOOL (WINAPI *pRemoveFontResourceEx)(LPCTSTR,DWORD,PVOID);
- BOOL (WINAPI *pMoveFileEx)(LPCTSTR, LPCTSTR,DWORD);
+ HANDLE(WINAPI* pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD*);
+ BOOL (WINAPI* pRemoveFontMemResourceEx)(HANDLE);
+ int (WINAPI* pAddFontResourceEx)(LPCTSTR, DWORD, PVOID);
+ BOOL (WINAPI* pRemoveFontResourceEx)(LPCTSTR, DWORD, PVOID);
+ BOOL (WINAPI* pMoveFileEx)(LPCTSTR, LPCTSTR, DWORD);
- CAtlList<HANDLE> m_fonts;
- CAtlList<CString> m_files;
- bool InstallFontFile(const void* pData, UINT len);
+ CAtlList<HANDLE> m_fonts;
+ CAtlList<CString> m_files;
+ bool InstallFontFile(const void* pData, UINT len);
public:
- CFontInstaller();
- virtual ~CFontInstaller();
+ CFontInstaller();
+ virtual ~CFontInstaller();
- bool InstallFont(const CAtlArray<BYTE>& data);
- bool InstallFont(const void* pData, UINT len);
- bool InstallFontMemory(const void* pData, UINT len);
- void UninstallFonts();
+ bool InstallFont(const CAtlArray<BYTE>& data);
+ bool InstallFont(const void* pData, UINT len);
+ bool InstallFontMemory(const void* pData, UINT len);
+ void UninstallFonts();
};
diff --git a/src/DSUtil/GolombBuffer.cpp b/src/DSUtil/GolombBuffer.cpp
index 5eeb9ffb1..1edb0167b 100644
--- a/src/DSUtil/GolombBuffer.cpp
+++ b/src/DSUtil/GolombBuffer.cpp
@@ -25,92 +25,92 @@
CGolombBuffer::CGolombBuffer(BYTE* pBuffer, int nSize)
{
- m_pBuffer = pBuffer;
- m_nSize = nSize;
+ m_pBuffer = pBuffer;
+ m_nSize = nSize;
- Reset();
+ Reset();
}
UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek)
{
- // ASSERT(nBits >= 0 && nBits <= 64);
+ // ASSERT(nBits >= 0 && nBits <= 64);
- while (m_bitlen < nBits) {
- m_bitbuff <<= 8;
+ while (m_bitlen < nBits) {
+ m_bitbuff <<= 8;
- if (m_nBitPos >= m_nSize) {
- return 0;
- }
+ if (m_nBitPos >= m_nSize) {
+ return 0;
+ }
- *(BYTE*)&m_bitbuff = m_pBuffer[m_nBitPos++];
- m_bitlen += 8;
- }
+ *(BYTE*)&m_bitbuff = m_pBuffer[m_nBitPos++];
+ m_bitlen += 8;
+ }
- int bitlen = m_bitlen - nBits;
+ int bitlen = m_bitlen - nBits;
- UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
+ UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if (!fPeek) {
- m_bitbuff &= ((1ui64 << bitlen) - 1);
- m_bitlen = bitlen;
- }
+ if (!fPeek) {
+ m_bitbuff &= ((1ui64 << bitlen) - 1);
+ m_bitlen = bitlen;
+ }
- return ret;
+ return ret;
}
UINT64 CGolombBuffer::UExpGolombRead()
{
- int n = -1;
- for (BYTE b = 0; !b; n++) {
- b = (BYTE)BitRead(1);
- }
- return (1ui64 << n) - 1 + BitRead(n);
+ int n = -1;
+ for (BYTE b = 0; !b; n++) {
+ b = (BYTE)BitRead(1);
+ }
+ return (1ui64 << n) - 1 + BitRead(n);
}
INT64 CGolombBuffer::SExpGolombRead()
{
- UINT64 k = UExpGolombRead();
- return ((k&1) ? 1 : -1) * ((k + 1) >> 1);
+ UINT64 k = UExpGolombRead();
+ return ((k & 1) ? 1 : -1) * ((k + 1) >> 1);
}
void CGolombBuffer::BitByteAlign()
{
- m_bitlen &= ~7;
+ m_bitlen &= ~7;
}
int CGolombBuffer::GetPos()
{
- return m_nBitPos - (m_bitlen>>3);
+ return m_nBitPos - (m_bitlen >> 3);
}
void CGolombBuffer::ReadBuffer(BYTE* pDest, int nSize)
{
- ASSERT (m_nBitPos + nSize <= m_nSize);
- ASSERT (m_bitlen == 0);
- nSize = min (nSize, m_nSize - m_nBitPos);
+ ASSERT(m_nBitPos + nSize <= m_nSize);
+ ASSERT(m_bitlen == 0);
+ nSize = min(nSize, m_nSize - m_nBitPos);
- memcpy (pDest, m_pBuffer+m_nBitPos, nSize);
- m_nBitPos += nSize;
+ memcpy(pDest, m_pBuffer + m_nBitPos, nSize);
+ m_nBitPos += nSize;
}
void CGolombBuffer::Reset()
{
- m_nBitPos = 0;
- m_bitlen = 0;
- m_bitbuff = 0;
+ m_nBitPos = 0;
+ m_bitlen = 0;
+ m_bitbuff = 0;
}
void CGolombBuffer::Reset(BYTE* pNewBuffer, int nNewSize)
{
- m_pBuffer = pNewBuffer;
- m_nSize = nNewSize;
+ m_pBuffer = pNewBuffer;
+ m_nSize = nNewSize;
- Reset();
+ Reset();
}
void CGolombBuffer::SkipBytes(int nCount)
{
- m_nBitPos += nCount;
- m_bitlen = 0;
- m_bitbuff = 0;
+ m_nBitPos += nCount;
+ m_bitlen = 0;
+ m_bitbuff = 0;
}
diff --git a/src/DSUtil/GolombBuffer.h b/src/DSUtil/GolombBuffer.h
index c151fb1d2..655afb856 100644
--- a/src/DSUtil/GolombBuffer.h
+++ b/src/DSUtil/GolombBuffer.h
@@ -25,34 +25,34 @@
class CGolombBuffer
{
public:
- CGolombBuffer(BYTE* pBuffer, int nSize);
+ CGolombBuffer(BYTE* pBuffer, int nSize);
- UINT64 BitRead(int nBits, bool fPeek = false);
- UINT64 UExpGolombRead();
- INT64 SExpGolombRead();
- void BitByteAlign();
+ UINT64 BitRead(int nBits, bool fPeek = false);
+ UINT64 UExpGolombRead();
+ INT64 SExpGolombRead();
+ void BitByteAlign();
- inline BYTE ReadByte() { return (BYTE)BitRead (8); };
- inline SHORT ReadShort() { return (SHORT)BitRead (16); };
- inline DWORD ReadDword() { return (DWORD)BitRead (32); };
- void ReadBuffer(BYTE* pDest, int nSize);
+ inline BYTE ReadByte() { return (BYTE)BitRead(8); };
+ inline SHORT ReadShort() { return (SHORT)BitRead(16); };
+ inline DWORD ReadDword() { return (DWORD)BitRead(32); };
+ void ReadBuffer(BYTE* pDest, int nSize);
- void Reset();
- void Reset(BYTE* pNewBuffer, int nNewSize);
+ void Reset();
+ void Reset(BYTE* pNewBuffer, int nNewSize);
- void SetSize(int nValue) { m_nSize = nValue; };
- int GetSize() const { return m_nSize; };
- int RemainingSize() const { return m_nSize - m_nBitPos; };
- bool IsEOF() const { return m_nBitPos >= m_nSize; };
- int GetPos();
- BYTE* GetBufferPos() { return m_pBuffer + m_nBitPos; };
+ void SetSize(int nValue) { m_nSize = nValue; };
+ int GetSize() const { return m_nSize; };
+ int RemainingSize() const { return m_nSize - m_nBitPos; };
+ bool IsEOF() const { return m_nBitPos >= m_nSize; };
+ int GetPos();
+ BYTE* GetBufferPos() { return m_pBuffer + m_nBitPos; };
- void SkipBytes(int nCount);
+ void SkipBytes(int nCount);
private :
- BYTE* m_pBuffer;
- int m_nSize;
- int m_nBitPos;
- int m_bitlen;
- INT64 m_bitbuff;
+ BYTE* m_pBuffer;
+ int m_nSize;
+ int m_nBitPos;
+ int m_bitlen;
+ INT64 m_bitbuff;
};
diff --git a/src/DSUtil/H264Nalu.cpp b/src/DSUtil/H264Nalu.cpp
index 7f5015b57..8286ce9b8 100644
--- a/src/DSUtil/H264Nalu.cpp
+++ b/src/DSUtil/H264Nalu.cpp
@@ -25,79 +25,79 @@
void CH264Nalu::SetBuffer(BYTE* pBuffer, int nSize, int nNALSize)
{
- m_pBuffer = pBuffer;
- m_nSize = nSize;
- m_nNALSize = nNALSize;
- m_nCurPos = 0;
- m_nNextRTP = 0;
+ m_pBuffer = pBuffer;
+ m_nSize = nSize;
+ m_nNALSize = nNALSize;
+ m_nCurPos = 0;
+ m_nNextRTP = 0;
- m_nNALStartPos = 0;
- m_nNALDataPos = 0;
+ m_nNALStartPos = 0;
+ m_nNALDataPos = 0;
- if (!nNALSize && nSize) {
- MoveToNextAnnexBStartcode();
- }
+ if (!nNALSize && nSize) {
+ MoveToNextAnnexBStartcode();
+ }
}
bool CH264Nalu::MoveToNextAnnexBStartcode()
{
- int nBuffEnd = m_nSize - 4;
+ int nBuffEnd = m_nSize - 4;
- for (int i=m_nCurPos; i<nBuffEnd; i++) {
- if ((*((DWORD*)(m_pBuffer+i)) & 0x00FFFFFF) == 0x00010000) {
- // Find next AnnexB Nal
- m_nCurPos = i;
- return true;
- }
- }
+ for (int i = m_nCurPos; i < nBuffEnd; i++) {
+ if ((*((DWORD*)(m_pBuffer + i)) & 0x00FFFFFF) == 0x00010000) {
+ // Find next AnnexB Nal
+ m_nCurPos = i;
+ return true;
+ }
+ }
- m_nCurPos = m_nSize;
- return false;
+ m_nCurPos = m_nSize;
+ return false;
}
bool CH264Nalu::MoveToNextRTPStartcode()
{
- if (m_nNextRTP < m_nSize) {
- m_nCurPos = m_nNextRTP;
- return true;
- }
+ if (m_nNextRTP < m_nSize) {
+ m_nCurPos = m_nNextRTP;
+ return true;
+ }
- m_nCurPos = m_nSize;
- return false;
+ m_nCurPos = m_nSize;
+ return false;
}
bool CH264Nalu::ReadNext()
{
- if ((m_nCurPos >= m_nSize) || (m_nCurPos<0)) {
- return false;
- }
+ if ((m_nCurPos >= m_nSize) || (m_nCurPos < 0)) {
+ return false;
+ }
- if ((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP)) {
- // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size
- m_nNALStartPos = m_nCurPos;
- m_nNALDataPos = m_nCurPos + m_nNALSize;
- unsigned nTemp = 0;
- for (int i=0; i<m_nNALSize; i++) {
- nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
- }
- m_nNextRTP += nTemp + m_nNALSize;
- MoveToNextRTPStartcode();
- } else {
- // Remove trailing bits
- while (m_pBuffer[m_nCurPos]==0x00 && ((*((DWORD*)(m_pBuffer+m_nCurPos)) & 0x00FFFFFF) != 0x00010000)) {
- m_nCurPos++;
- }
+ if ((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP)) {
+ // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size
+ m_nNALStartPos = m_nCurPos;
+ m_nNALDataPos = m_nCurPos + m_nNALSize;
+ unsigned nTemp = 0;
+ for (int i = 0; i < m_nNALSize; i++) {
+ nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
+ }
+ m_nNextRTP += nTemp + m_nNALSize;
+ MoveToNextRTPStartcode();
+ } else {
+ // Remove trailing bits
+ while (m_pBuffer[m_nCurPos] == 0x00 && ((*((DWORD*)(m_pBuffer + m_nCurPos)) & 0x00FFFFFF) != 0x00010000)) {
+ m_nCurPos++;
+ }
- // AnnexB Nalu : 00 00 01 NAL...
- m_nNALStartPos = m_nCurPos;
- m_nCurPos += 3;
- m_nNALDataPos = m_nCurPos;
- MoveToNextAnnexBStartcode();
- }
+ // AnnexB Nalu : 00 00 01 NAL...
+ m_nNALStartPos = m_nCurPos;
+ m_nCurPos += 3;
+ m_nNALDataPos = m_nCurPos;
+ MoveToNextAnnexBStartcode();
+ }
- forbidden_bit = (m_pBuffer[m_nNALDataPos]>>7) & 1;
- nal_reference_idc = (m_pBuffer[m_nNALDataPos]>>5) & 3;
- nal_unit_type = (NALU_TYPE) (m_pBuffer[m_nNALDataPos] & 0x1f);
+ forbidden_bit = (m_pBuffer[m_nNALDataPos] >> 7) & 1;
+ nal_reference_idc = (m_pBuffer[m_nNALDataPos] >> 5) & 3;
+ nal_unit_type = (NALU_TYPE)(m_pBuffer[m_nNALDataPos] & 0x1f);
- return true;
+ return true;
}
diff --git a/src/DSUtil/H264Nalu.h b/src/DSUtil/H264Nalu.h
index d64f22dac..a00d12294 100644
--- a/src/DSUtil/H264Nalu.h
+++ b/src/DSUtil/H264Nalu.h
@@ -23,56 +23,56 @@
#pragma once
typedef enum {
- NALU_TYPE_SLICE = 1,
- NALU_TYPE_DPA = 2,
- NALU_TYPE_DPB = 3,
- NALU_TYPE_DPC = 4,
- NALU_TYPE_IDR = 5,
- NALU_TYPE_SEI = 6,
- NALU_TYPE_SPS = 7,
- NALU_TYPE_PPS = 8,
- NALU_TYPE_AUD = 9,
- NALU_TYPE_EOSEQ = 10,
- NALU_TYPE_EOSTREAM = 11,
- NALU_TYPE_FILL = 12
+ NALU_TYPE_SLICE = 1,
+ NALU_TYPE_DPA = 2,
+ NALU_TYPE_DPB = 3,
+ NALU_TYPE_DPC = 4,
+ NALU_TYPE_IDR = 5,
+ NALU_TYPE_SEI = 6,
+ NALU_TYPE_SPS = 7,
+ NALU_TYPE_PPS = 8,
+ NALU_TYPE_AUD = 9,
+ NALU_TYPE_EOSEQ = 10,
+ NALU_TYPE_EOSTREAM = 11,
+ NALU_TYPE_FILL = 12
} NALU_TYPE;
class CH264Nalu
{
private :
- int forbidden_bit; //! should be always FALSE
- int nal_reference_idc; //! NALU_PRIORITY_xxxx
- NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx
+ int forbidden_bit; //! should be always FALSE
+ int nal_reference_idc; //! NALU_PRIORITY_xxxx
+ NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx
- int m_nNALStartPos; //! NALU start (including startcode / size)
- int m_nNALDataPos; //! Useful part
+ int m_nNALStartPos; //! NALU start (including startcode / size)
+ int m_nNALDataPos; //! Useful part
- BYTE* m_pBuffer;
- int m_nCurPos;
- int m_nNextRTP;
- int m_nSize;
- int m_nNALSize;
+ BYTE* m_pBuffer;
+ int m_nCurPos;
+ int m_nNextRTP;
+ int m_nSize;
+ int m_nNALSize;
- bool MoveToNextAnnexBStartcode();
- bool MoveToNextRTPStartcode();
+ bool MoveToNextAnnexBStartcode();
+ bool MoveToNextRTPStartcode();
public :
- CH264Nalu() { SetBuffer(NULL, 0, 0); }
+ CH264Nalu() { SetBuffer(NULL, 0, 0); }
- NALU_TYPE GetType() const { return nal_unit_type; };
- bool IsRefFrame() const { return (nal_reference_idc != 0); };
+ NALU_TYPE GetType() const { return nal_unit_type; };
+ bool IsRefFrame() const { return (nal_reference_idc != 0); };
- int GetDataLength() const { return m_nCurPos - m_nNALDataPos; };
- BYTE* GetDataBuffer() { return m_pBuffer + m_nNALDataPos; };
- int GetRoundedDataLength() const {
- int nSize = m_nCurPos - m_nNALDataPos;
- return nSize + 128 - (nSize %128);
- }
+ int GetDataLength() const { return m_nCurPos - m_nNALDataPos; };
+ BYTE* GetDataBuffer() { return m_pBuffer + m_nNALDataPos; };
+ int GetRoundedDataLength() const {
+ int nSize = m_nCurPos - m_nNALDataPos;
+ return nSize + 128 - (nSize % 128);
+ }
- int GetLength() const { return m_nCurPos - m_nNALStartPos; };
- BYTE* GetNALBuffer() { return m_pBuffer + m_nNALStartPos; };
- bool IsEOF() const { return m_nCurPos >= m_nSize; };
+ int GetLength() const { return m_nCurPos - m_nNALStartPos; };
+ BYTE* GetNALBuffer() { return m_pBuffer + m_nNALStartPos; };
+ bool IsEOF() const { return m_nCurPos >= m_nSize; };
- void SetBuffer(BYTE* pBuffer, int nSize, int nNALSize);
- bool ReadNext();
+ void SetBuffer(BYTE* pBuffer, int nSize, int nNALSize);
+ bool ReadNext();
};
diff --git a/src/DSUtil/HdmvClipInfo.cpp b/src/DSUtil/HdmvClipInfo.cpp
index ecf95afc6..81ace7d83 100644
--- a/src/DSUtil/HdmvClipInfo.cpp
+++ b/src/DSUtil/HdmvClipInfo.cpp
@@ -28,443 +28,440 @@ extern LCID ISO6392ToLcid(LPCSTR code);
CHdmvClipInfo::CHdmvClipInfo(void)
{
- m_hFile = INVALID_HANDLE_VALUE;
- m_bIsHdmv = false;
+ m_hFile = INVALID_HANDLE_VALUE;
+ m_bIsHdmv = false;
}
CHdmvClipInfo::~CHdmvClipInfo()
{
- CloseFile(S_OK);
+ CloseFile(S_OK);
}
HRESULT CHdmvClipInfo::CloseFile(HRESULT hr)
{
- if (m_hFile != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- }
- return hr;
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ }
+ return hr;
}
DWORD CHdmvClipInfo::ReadDword()
{
- return ReadByte()<<24 | ReadByte()<<16 | ReadByte()<<8 | ReadByte();
+ return ReadByte() << 24 | ReadByte() << 16 | ReadByte() << 8 | ReadByte();
}
SHORT CHdmvClipInfo::ReadShort()
{
- return ReadByte()<<8 | ReadByte();
+ return ReadByte() << 8 | ReadByte();
}
BYTE CHdmvClipInfo::ReadByte()
{
- BYTE bVal;
- DWORD dwRead;
- ReadFile (m_hFile, &bVal, sizeof(bVal), &dwRead, NULL);
+ BYTE bVal;
+ DWORD dwRead;
+ ReadFile(m_hFile, &bVal, sizeof(bVal), &dwRead, NULL);
- return bVal;
+ return bVal;
}
void CHdmvClipInfo::ReadBuffer(BYTE* pBuff, DWORD nLen)
{
- DWORD dwRead;
- ReadFile (m_hFile, pBuff, nLen, &dwRead, NULL);
+ DWORD dwRead;
+ ReadFile(m_hFile, pBuff, nLen, &dwRead, NULL);
}
HRESULT CHdmvClipInfo::ReadProgramInfo()
{
- BYTE number_of_program_sequences;
- BYTE number_of_streams_in_ps;
- LARGE_INTEGER Pos;
-
- m_Streams.RemoveAll();
- Pos.QuadPart = ProgramInfo_start_address;
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
-
- ReadDword(); //length
- ReadByte(); //reserved_for_word_align
- number_of_program_sequences = (BYTE)ReadByte();
- int iStream = 0;
- for (size_t i=0; i<number_of_program_sequences; i++) {
- ReadDword(); //SPN_program_sequence_start
- ReadShort(); //program_map_PID
- number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
- ReadByte(); //reserved_for_future_use
-
- for (size_t stream_index=0; stream_index<number_of_streams_in_ps; stream_index++) {
- m_Streams.SetCount(iStream + 1);
- m_Streams[iStream].m_PID = ReadShort(); // stream_PID
-
- // == StreamCodingInfo
- Pos.QuadPart = 0;
- SetFilePointerEx(m_hFile, Pos, &Pos, FILE_CURRENT);
- Pos.QuadPart += ReadByte() + 1; // length
- m_Streams[iStream].m_Type = (PES_STREAM_TYPE)ReadByte();
-
- switch (m_Streams[iStream].m_Type) {
- case VIDEO_STREAM_MPEG1:
- case VIDEO_STREAM_MPEG2:
- case VIDEO_STREAM_H264:
- case VIDEO_STREAM_VC1: {
- uint8 Temp = ReadByte();
- BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
- BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
- Temp = ReadByte();
- BDVM_AspectRatio AspectRatio = (BDVM_AspectRatio)(Temp >> 4);
-
- m_Streams[iStream].m_VideoFormat = VideoFormat;
- m_Streams[iStream].m_FrameRate = FrameRate;
- m_Streams[iStream].m_AspectRatio = AspectRatio;
- }
- break;
- case AUDIO_STREAM_MPEG1:
- case AUDIO_STREAM_MPEG2:
- case AUDIO_STREAM_LPCM:
- case AUDIO_STREAM_AC3:
- case AUDIO_STREAM_DTS:
- case AUDIO_STREAM_AC3_TRUE_HD:
- case AUDIO_STREAM_AC3_PLUS:
- case AUDIO_STREAM_DTS_HD:
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- case SECONDARY_AUDIO_AC3_PLUS:
- case SECONDARY_AUDIO_DTS_HD: {
- uint8 Temp = ReadByte();
- BDVM_ChannelLayout ChannelLayout = (BDVM_ChannelLayout)(Temp >> 4);
- BDVM_SampleRate SampleRate = (BDVM_SampleRate)(Temp & 0xF);
-
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
- m_Streams[iStream].m_ChannelLayout = ChannelLayout;
- m_Streams[iStream].m_SampleRate = SampleRate;
- }
- break;
- case PRESENTATION_GRAPHICS_STREAM:
- case INTERACTIVE_GRAPHICS_STREAM: {
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
- }
- break;
- case SUBTITLE_STREAM: {
- ReadByte(); // Should this really be here?
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
- }
- break;
- default :
- break;
- }
-
- iStream++;
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- }
- }
- return S_OK;
+ BYTE number_of_program_sequences;
+ BYTE number_of_streams_in_ps;
+ LARGE_INTEGER Pos;
+
+ m_Streams.RemoveAll();
+ Pos.QuadPart = ProgramInfo_start_address;
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+
+ ReadDword(); //length
+ ReadByte(); //reserved_for_word_align
+ number_of_program_sequences = (BYTE)ReadByte();
+ int iStream = 0;
+ for (size_t i = 0; i < number_of_program_sequences; i++) {
+ ReadDword(); //SPN_program_sequence_start
+ ReadShort(); //program_map_PID
+ number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
+ ReadByte(); //reserved_for_future_use
+
+ for (size_t stream_index = 0; stream_index < number_of_streams_in_ps; stream_index++) {
+ m_Streams.SetCount(iStream + 1);
+ m_Streams[iStream].m_PID = ReadShort(); // stream_PID
+
+ // == StreamCodingInfo
+ Pos.QuadPart = 0;
+ SetFilePointerEx(m_hFile, Pos, &Pos, FILE_CURRENT);
+ Pos.QuadPart += ReadByte() + 1; // length
+ m_Streams[iStream].m_Type = (PES_STREAM_TYPE)ReadByte();
+
+ switch (m_Streams[iStream].m_Type) {
+ case VIDEO_STREAM_MPEG1:
+ case VIDEO_STREAM_MPEG2:
+ case VIDEO_STREAM_H264:
+ case VIDEO_STREAM_VC1: {
+ uint8 Temp = ReadByte();
+ BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
+ BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
+ Temp = ReadByte();
+ BDVM_AspectRatio AspectRatio = (BDVM_AspectRatio)(Temp >> 4);
+
+ m_Streams[iStream].m_VideoFormat = VideoFormat;
+ m_Streams[iStream].m_FrameRate = FrameRate;
+ m_Streams[iStream].m_AspectRatio = AspectRatio;
+ }
+ break;
+ case AUDIO_STREAM_MPEG1:
+ case AUDIO_STREAM_MPEG2:
+ case AUDIO_STREAM_LPCM:
+ case AUDIO_STREAM_AC3:
+ case AUDIO_STREAM_DTS:
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ case AUDIO_STREAM_AC3_PLUS:
+ case AUDIO_STREAM_DTS_HD:
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ case SECONDARY_AUDIO_AC3_PLUS:
+ case SECONDARY_AUDIO_DTS_HD: {
+ uint8 Temp = ReadByte();
+ BDVM_ChannelLayout ChannelLayout = (BDVM_ChannelLayout)(Temp >> 4);
+ BDVM_SampleRate SampleRate = (BDVM_SampleRate)(Temp & 0xF);
+
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
+ m_Streams[iStream].m_ChannelLayout = ChannelLayout;
+ m_Streams[iStream].m_SampleRate = SampleRate;
+ }
+ break;
+ case PRESENTATION_GRAPHICS_STREAM:
+ case INTERACTIVE_GRAPHICS_STREAM: {
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
+ }
+ break;
+ case SUBTITLE_STREAM: {
+ ReadByte(); // Should this really be here?
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
+ }
+ break;
+ default :
+ break;
+ }
+
+ iStream++;
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ }
+ }
+ return S_OK;
}
HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
{
- BYTE Buff[100];
+ BYTE Buff[100];
- m_bIsHdmv = false;
- m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ m_bIsHdmv = false;
+ m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if (m_hFile != INVALID_HANDLE_VALUE) {
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "HDMV", 4)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "HDMV", 4)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
- ReadBuffer(Buff, 4);
- if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) {
- return CloseFile (VFW_E_INVALID_FILE_FORMAT);
- }
+ ReadBuffer(Buff, 4);
+ if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
- SequenceInfo_start_address = ReadDword();
- ProgramInfo_start_address = ReadDword();
+ SequenceInfo_start_address = ReadDword();
+ ProgramInfo_start_address = ReadDword();
- ReadProgramInfo();
+ ReadProgramInfo();
- m_bIsHdmv = true;
+ m_bIsHdmv = true;
- return CloseFile(S_OK);
- }
+ return CloseFile(S_OK);
+ }
- return AmHresultFromWin32(GetLastError());
+ return AmHresultFromWin32(GetLastError());
}
CHdmvClipInfo::Stream* CHdmvClipInfo::FindStream(SHORT wPID)
{
- size_t nStreams = m_Streams.GetCount();
- for (size_t i=0; i<nStreams; i++) {
- if (m_Streams[i].m_PID == wPID) {
- return &m_Streams[i];
- }
- }
-
- return NULL;
+ size_t nStreams = m_Streams.GetCount();
+ for (size_t i = 0; i < nStreams; i++) {
+ if (m_Streams[i].m_PID == wPID) {
+ return &m_Streams[i];
+ }
+ }
+
+ return NULL;
}
LPCTSTR CHdmvClipInfo::Stream::Format()
{
- switch (m_Type) {
- case VIDEO_STREAM_MPEG1:
- return _T("Mpeg1");
- case VIDEO_STREAM_MPEG2:
- return _T("Mpeg2");
- case VIDEO_STREAM_H264:
- return _T("H264");
- case VIDEO_STREAM_VC1:
- return _T("VC1");
- case AUDIO_STREAM_MPEG1:
- return _T("MPEG1");
- case AUDIO_STREAM_MPEG2:
- return _T("MPEG2");
- case AUDIO_STREAM_LPCM:
- return _T("LPCM");
- case AUDIO_STREAM_AC3:
- return _T("AC3");
- case AUDIO_STREAM_DTS:
- return _T("DTS");
- case AUDIO_STREAM_AC3_TRUE_HD:
- return _T("MLP");
- case AUDIO_STREAM_AC3_PLUS:
- return _T("DD+");
- case AUDIO_STREAM_DTS_HD:
- return _T("DTS-HD");
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- return _T("DTS-HD XLL");
- case SECONDARY_AUDIO_AC3_PLUS:
- return _T("Sec DD+");
- case SECONDARY_AUDIO_DTS_HD:
- return _T("Sec DTS-HD");
- case PRESENTATION_GRAPHICS_STREAM :
- return _T("PG");
- case INTERACTIVE_GRAPHICS_STREAM :
- return _T("IG");
- case SUBTITLE_STREAM :
- return _T("Text");
- default :
- return _T("Unknown");
- }
+ switch (m_Type) {
+ case VIDEO_STREAM_MPEG1:
+ return _T("Mpeg1");
+ case VIDEO_STREAM_MPEG2:
+ return _T("Mpeg2");
+ case VIDEO_STREAM_H264:
+ return _T("H264");
+ case VIDEO_STREAM_VC1:
+ return _T("VC1");
+ case AUDIO_STREAM_MPEG1:
+ return _T("MPEG1");
+ case AUDIO_STREAM_MPEG2:
+ return _T("MPEG2");
+ case AUDIO_STREAM_LPCM:
+ return _T("LPCM");
+ case AUDIO_STREAM_AC3:
+ return _T("AC3");
+ case AUDIO_STREAM_DTS:
+ return _T("DTS");
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ return _T("MLP");
+ case AUDIO_STREAM_AC3_PLUS:
+ return _T("DD+");
+ case AUDIO_STREAM_DTS_HD:
+ return _T("DTS-HD");
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ return _T("DTS-HD XLL");
+ case SECONDARY_AUDIO_AC3_PLUS:
+ return _T("Sec DD+");
+ case SECONDARY_AUDIO_DTS_HD:
+ return _T("Sec DTS-HD");
+ case PRESENTATION_GRAPHICS_STREAM :
+ return _T("PG");
+ case INTERACTIVE_GRAPHICS_STREAM :
+ return _T("IG");
+ case SUBTITLE_STREAM :
+ return _T("Text");
+ default :
+ return _T("Unknown");
+ }
}
HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist)
{
- BYTE Buff[100];
- CPath Path (strPlaylistFile);
- bool bDuplicate = false;
- rtDuration = 0;
-
- // Get BDMV folder
- Path.RemoveFileSpec();
- Path.RemoveFileSpec();
-
- m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
-
- if (m_hFile != INVALID_HANDLE_VALUE) {
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "MPLS", 4)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- ReadBuffer(Buff, 4);
- if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- LARGE_INTEGER Pos;
- DWORD dwTemp;
- USHORT nPlaylistItems;
-
- Pos.QuadPart = ReadDword(); // PlayList_start_address
- ReadDword(); // PlayListMark_start_address
-
- // PlayList()
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- ReadDword(); // length
- ReadShort(); // reserved_for_future_use
- nPlaylistItems = ReadShort(); // number_of_PlayItems
- ReadShort(); // number_of_SubPaths
-
- Pos.QuadPart += 10;
- for (size_t i=0; i<nPlaylistItems; i++) {
- PlaylistItem Item;
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- Pos.QuadPart += ReadShort() + 2;
- ReadBuffer(Buff, 5);
- Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);
-
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "M2TS", 4)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
- ReadBuffer(Buff, 3);
-
- dwTemp = ReadDword();
- Item.m_rtIn = 20000i64*dwTemp/90; // Carefull : 32->33 bits!
-
- dwTemp = ReadDword();
- Item.m_rtOut = 20000i64*dwTemp/90; // Carefull : 32->33 bits!
-
- rtDuration += (Item.m_rtOut - Item.m_rtIn);
-
- if (Playlist.Find(Item) != NULL) {
- bDuplicate = true;
- }
- Playlist.AddTail (Item);
-
- //TRACE ("File : %S, Duration : %S, Total duration : %S\n", strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration));
- }
-
- CloseFile (S_OK);
- return bDuplicate ? S_FALSE : S_OK;
- }
-
- return AmHresultFromWin32(GetLastError());
+ BYTE Buff[100];
+ CPath Path(strPlaylistFile);
+ bool bDuplicate = false;
+ rtDuration = 0;
+
+ // Get BDMV folder
+ Path.RemoveFileSpec();
+ Path.RemoveFileSpec();
+
+ m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "MPLS", 4)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ ReadBuffer(Buff, 4);
+ if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ LARGE_INTEGER Pos;
+ DWORD dwTemp;
+ USHORT nPlaylistItems;
+
+ Pos.QuadPart = ReadDword(); // PlayList_start_address
+ ReadDword(); // PlayListMark_start_address
+
+ // PlayList()
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ ReadDword(); // length
+ ReadShort(); // reserved_for_future_use
+ nPlaylistItems = ReadShort(); // number_of_PlayItems
+ ReadShort(); // number_of_SubPaths
+
+ Pos.QuadPart += 10;
+ for (size_t i = 0; i < nPlaylistItems; i++) {
+ PlaylistItem Item;
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ Pos.QuadPart += ReadShort() + 2;
+ ReadBuffer(Buff, 5);
+ Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);
+
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "M2TS", 4)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+ ReadBuffer(Buff, 3);
+
+ dwTemp = ReadDword();
+ Item.m_rtIn = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!
+
+ dwTemp = ReadDword();
+ Item.m_rtOut = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!
+
+ rtDuration += (Item.m_rtOut - Item.m_rtIn);
+
+ if (Playlist.Find(Item) != NULL) {
+ bDuplicate = true;
+ }
+ Playlist.AddTail(Item);
+
+ //TRACE ("File : %S, Duration : %S, Total duration : %S\n", strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration));
+ }
+
+ CloseFile(S_OK);
+ return bDuplicate ? S_FALSE : S_OK;
+ }
+
+ return AmHresultFromWin32(GetLastError());
}
HRESULT CHdmvClipInfo::ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters)
{
- BYTE Buff[100];
- CPath Path (strPlaylistFile);
- bool bDuplicate = false;
-
- // Get BDMV folder
- Path.RemoveFileSpec();
- Path.RemoveFileSpec();
-
- m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
-
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
- REFERENCE_TIME* rtOffset = new REFERENCE_TIME[PlaylistItems.GetCount()];
- REFERENCE_TIME rtSum = 0;
- int nIndex = 0;
-
- POSITION pos = PlaylistItems.GetHeadPosition();
- while (pos)
- {
- CHdmvClipInfo::PlaylistItem& PI = PlaylistItems.GetNext(pos);
-
- rtOffset[nIndex] = rtSum - PI.m_rtIn;
- rtSum = rtSum + PI.Duration();
- nIndex++;
- }
-
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "MPLS", 4)) {
- SAFE_DELETE_ARRAY(rtOffset);
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- ReadBuffer(Buff, 4);
- if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) {
- SAFE_DELETE_ARRAY(rtOffset);
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- LARGE_INTEGER Pos;
- USHORT nMarkCount;
-
- ReadDword(); // PlayList_start_address
- Pos.QuadPart = ReadDword(); // PlayListMark_start_address
-
- // PlayListMark()
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- ReadDword(); // length
- nMarkCount = ReadShort(); // number_of_PlayList_marks
- for (size_t i=0; i<nMarkCount; i++)
- {
- PlaylistChapter Chapter;
-
- ReadByte(); // reserved_for_future_use
- Chapter.m_nMarkType = (PlaylistMarkType)ReadByte(); // mark_type
- Chapter.m_nPlayItemId = ReadShort(); // ref_to_PlayItem_id
- Chapter.m_rtTimestamp = 20000i64*ReadDword()/90 + rtOffset[Chapter.m_nPlayItemId]; // mark_time_stamp
- Chapter.m_nEntryPID = ReadShort(); // entry_ES_PID
- Chapter.m_rtDuration = 20000i64*ReadDword()/90; // duration
-
- Chapters.AddTail (Chapter);
-
- // TRACE ("Chapter %d : %S\n", i, ReftimeToString (Chapter.m_rtTimestamp));
- }
-
- CloseFile (S_OK);
- SAFE_DELETE_ARRAY(rtOffset);
- return bDuplicate ? S_FALSE : S_OK;
- }
-
- return AmHresultFromWin32(GetLastError());
+ BYTE Buff[100];
+ CPath Path(strPlaylistFile);
+ bool bDuplicate = false;
+
+ // Get BDMV folder
+ Path.RemoveFileSpec();
+ Path.RemoveFileSpec();
+
+ m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ REFERENCE_TIME* rtOffset = new REFERENCE_TIME[PlaylistItems.GetCount()];
+ REFERENCE_TIME rtSum = 0;
+ int nIndex = 0;
+
+ POSITION pos = PlaylistItems.GetHeadPosition();
+ while (pos) {
+ CHdmvClipInfo::PlaylistItem& PI = PlaylistItems.GetNext(pos);
+
+ rtOffset[nIndex] = rtSum - PI.m_rtIn;
+ rtSum = rtSum + PI.Duration();
+ nIndex++;
+ }
+
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "MPLS", 4)) {
+ SAFE_DELETE_ARRAY(rtOffset);
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ ReadBuffer(Buff, 4);
+ if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
+ SAFE_DELETE_ARRAY(rtOffset);
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ LARGE_INTEGER Pos;
+ USHORT nMarkCount;
+
+ ReadDword(); // PlayList_start_address
+ Pos.QuadPart = ReadDword(); // PlayListMark_start_address
+
+ // PlayListMark()
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ ReadDword(); // length
+ nMarkCount = ReadShort(); // number_of_PlayList_marks
+ for (size_t i = 0; i < nMarkCount; i++) {
+ PlaylistChapter Chapter;
+
+ ReadByte(); // reserved_for_future_use
+ Chapter.m_nMarkType = (PlaylistMarkType)ReadByte(); // mark_type
+ Chapter.m_nPlayItemId = ReadShort(); // ref_to_PlayItem_id
+ Chapter.m_rtTimestamp = 20000i64 * ReadDword() / 90 + rtOffset[Chapter.m_nPlayItemId]; // mark_time_stamp
+ Chapter.m_nEntryPID = ReadShort(); // entry_ES_PID
+ Chapter.m_rtDuration = 20000i64 * ReadDword() / 90; // duration
+
+ Chapters.AddTail(Chapter);
+
+ // TRACE ("Chapter %d : %S\n", i, ReftimeToString (Chapter.m_rtTimestamp));
+ }
+
+ CloseFile(S_OK);
+ SAFE_DELETE_ARRAY(rtOffset);
+ return bDuplicate ? S_FALSE : S_OK;
+ }
+
+ return AmHresultFromWin32(GetLastError());
}
#define MIN_LIMIT 3
HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists)
{
- HRESULT hr = E_FAIL;
-
- CString strPath (strFolder);
- CString strFilter;
-
- MPLSPlaylists.RemoveAll();
-
- CAtlList<PlaylistItem> Playlist;
- WIN32_FIND_DATA fd = {0};
-
- strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
- strPath.Replace(_T("\\STREAM\\"), _T("\\"));
- strPath += _T("\\BDMV\\");
- strFilter.Format (_T("%sPLAYLIST\\*.mpls"), strPath);
-
- HANDLE hFind = FindFirstFile(strFilter, &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- REFERENCE_TIME rtMax = 0;
- REFERENCE_TIME rtCurrent;
- CString strCurrentPlaylist;
- do {
- strCurrentPlaylist.Format(_T("%sPLAYLIST\\%s"), strPath, fd.cFileName);
- Playlist.RemoveAll();
-
- // Main movie shouldn't have duplicate M2TS filename...
- if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK) {
- if (rtCurrent > rtMax) {
- rtMax = rtCurrent;
- strPlaylistFile = strCurrentPlaylist;
- MainPlaylist.RemoveAll();
- POSITION pos = Playlist.GetHeadPosition();
- while (pos) {
- MainPlaylist.AddTail(Playlist.GetNext(pos));
- }
- hr = S_OK;
- }
- if (rtCurrent >= (REFERENCE_TIME)MIN_LIMIT*600000000) {
- PlaylistItem Item;
- Item.m_strFileName = strCurrentPlaylist;
- Item.m_rtIn = 0;
- Item.m_rtOut = rtCurrent;
- MPLSPlaylists.AddTail(Item);
- }
-
- }
- } while (FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
-
- if (MPLSPlaylists.GetCount() > 1) {
- // bubble sort
- for (size_t j=0; j<MPLSPlaylists.GetCount(); j++) {
- for (size_t i=0; i<MPLSPlaylists.GetCount()-1; i++) {
- if (MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i)).Duration() < MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i+1)).Duration()) {
- MPLSPlaylists.SwapElements(MPLSPlaylists.FindIndex(i), MPLSPlaylists.FindIndex(i+1));
- }
- }
- }
- }
-
- return hr;
+ HRESULT hr = E_FAIL;
+
+ CString strPath(strFolder);
+ CString strFilter;
+
+ MPLSPlaylists.RemoveAll();
+
+ CAtlList<PlaylistItem> Playlist;
+ WIN32_FIND_DATA fd = {0};
+
+ strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
+ strPath.Replace(_T("\\STREAM\\"), _T("\\"));
+ strPath += _T("\\BDMV\\");
+ strFilter.Format(_T("%sPLAYLIST\\*.mpls"), strPath);
+
+ HANDLE hFind = FindFirstFile(strFilter, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ REFERENCE_TIME rtMax = 0;
+ REFERENCE_TIME rtCurrent;
+ CString strCurrentPlaylist;
+ do {
+ strCurrentPlaylist.Format(_T("%sPLAYLIST\\%s"), strPath, fd.cFileName);
+ Playlist.RemoveAll();
+
+ // Main movie shouldn't have duplicate M2TS filename...
+ if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK) {
+ if (rtCurrent > rtMax) {
+ rtMax = rtCurrent;
+ strPlaylistFile = strCurrentPlaylist;
+ MainPlaylist.RemoveAll();
+ POSITION pos = Playlist.GetHeadPosition();
+ while (pos) {
+ MainPlaylist.AddTail(Playlist.GetNext(pos));
+ }
+ hr = S_OK;
+ }
+ if (rtCurrent >= (REFERENCE_TIME)MIN_LIMIT * 600000000) {
+ PlaylistItem Item;
+ Item.m_strFileName = strCurrentPlaylist;
+ Item.m_rtIn = 0;
+ Item.m_rtOut = rtCurrent;
+ MPLSPlaylists.AddTail(Item);
+ }
+
+ }
+ } while (FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+
+ if (MPLSPlaylists.GetCount() > 1) {
+ // bubble sort
+ for (size_t j = 0; j < MPLSPlaylists.GetCount(); j++) {
+ for (size_t i = 0; i < MPLSPlaylists.GetCount() - 1; i++) {
+ if (MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i)).Duration() < MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i + 1)).Duration()) {
+ MPLSPlaylists.SwapElements(MPLSPlaylists.FindIndex(i), MPLSPlaylists.FindIndex(i + 1));
+ }
+ }
+ }
+ }
+
+ return hr;
}
diff --git a/src/DSUtil/HdmvClipInfo.h b/src/DSUtil/HdmvClipInfo.h
index 11136f1a6..a262fb954 100644
--- a/src/DSUtil/HdmvClipInfo.h
+++ b/src/DSUtil/HdmvClipInfo.h
@@ -25,48 +25,48 @@
#include "Mpeg2Def.h"
enum BDVM_VideoFormat {
- BDVM_VideoFormat_Unknown = 0,
- BDVM_VideoFormat_480i = 1,
- BDVM_VideoFormat_576i = 2,
- BDVM_VideoFormat_480p = 3,
- BDVM_VideoFormat_1080i = 4,
- BDVM_VideoFormat_720p = 5,
- BDVM_VideoFormat_1080p = 6,
- BDVM_VideoFormat_576p = 7,
+ BDVM_VideoFormat_Unknown = 0,
+ BDVM_VideoFormat_480i = 1,
+ BDVM_VideoFormat_576i = 2,
+ BDVM_VideoFormat_480p = 3,
+ BDVM_VideoFormat_1080i = 4,
+ BDVM_VideoFormat_720p = 5,
+ BDVM_VideoFormat_1080p = 6,
+ BDVM_VideoFormat_576p = 7,
};
enum BDVM_FrameRate {
- BDVM_FrameRate_Unknown = 0,
- BDVM_FrameRate_23_976 = 1,
- BDVM_FrameRate_24 = 2,
- BDVM_FrameRate_25 = 3,
- BDVM_FrameRate_29_97 = 4,
- BDVM_FrameRate_50 = 6,
- BDVM_FrameRate_59_94 = 7
+ BDVM_FrameRate_Unknown = 0,
+ BDVM_FrameRate_23_976 = 1,
+ BDVM_FrameRate_24 = 2,
+ BDVM_FrameRate_25 = 3,
+ BDVM_FrameRate_29_97 = 4,
+ BDVM_FrameRate_50 = 6,
+ BDVM_FrameRate_59_94 = 7
};
enum BDVM_AspectRatio {
- BDVM_AspectRatio_Unknown = 0,
- BDVM_AspectRatio_4_3 = 2,
- BDVM_AspectRatio_16_9 = 3,
- BDVM_AspectRatio_2_21 = 4
+ BDVM_AspectRatio_Unknown = 0,
+ BDVM_AspectRatio_4_3 = 2,
+ BDVM_AspectRatio_16_9 = 3,
+ BDVM_AspectRatio_2_21 = 4
};
enum BDVM_ChannelLayout {
- BDVM_ChannelLayout_Unknown = 0,
- BDVM_ChannelLayout_MONO = 1,
- BDVM_ChannelLayout_STEREO = 3,
- BDVM_ChannelLayout_MULTI = 6,
- BDVM_ChannelLayout_COMBO = 12
+ BDVM_ChannelLayout_Unknown = 0,
+ BDVM_ChannelLayout_MONO = 1,
+ BDVM_ChannelLayout_STEREO = 3,
+ BDVM_ChannelLayout_MULTI = 6,
+ BDVM_ChannelLayout_COMBO = 12
};
enum BDVM_SampleRate {
- BDVM_SampleRate_Unknown = 0,
- BDVM_SampleRate_48 = 1,
- BDVM_SampleRate_96 = 4,
- BDVM_SampleRate_192 = 5,
- BDVM_SampleRate_48_192 = 12,
- BDVM_SampleRate_48_96 = 14
+ BDVM_SampleRate_Unknown = 0,
+ BDVM_SampleRate_48 = 1,
+ BDVM_SampleRate_96 = 4,
+ BDVM_SampleRate_192 = 5,
+ BDVM_SampleRate_48_192 = 12,
+ BDVM_SampleRate_48_96 = 14
};
typedef unsigned char uint8;
@@ -83,83 +83,81 @@ class CHdmvClipInfo
{
public:
- struct Stream {
- Stream() {
- memset(this, 0, sizeof(*this));
- }
- SHORT m_PID;
- PES_STREAM_TYPE m_Type;
- char m_LanguageCode[4];
- LCID m_LCID;
-
- // Valid for video types
- BDVM_VideoFormat m_VideoFormat;
- BDVM_FrameRate m_FrameRate;
- BDVM_AspectRatio m_AspectRatio;
- // Valid for audio types
- BDVM_ChannelLayout m_ChannelLayout;
- BDVM_SampleRate m_SampleRate;
-
- LPCTSTR Format();
- };
-
- struct PlaylistItem {
- CString m_strFileName;
- REFERENCE_TIME m_rtIn;
- REFERENCE_TIME m_rtOut;
-
- REFERENCE_TIME Duration() const {
- return m_rtOut - m_rtIn;
- }
-
- bool operator == (const PlaylistItem& pi) const {
- return pi.m_strFileName == m_strFileName;
- }
- };
-
- enum PlaylistMarkType
- {
- Reserved = 0x00,
- EntryMark = 0x01,
- LinkPoint = 0x02
- };
-
- struct PlaylistChapter
- {
- SHORT m_nPlayItemId;
- PlaylistMarkType m_nMarkType;
- REFERENCE_TIME m_rtTimestamp;
- SHORT m_nEntryPID;
- REFERENCE_TIME m_rtDuration;
- };
-
- CHdmvClipInfo(void);
- ~CHdmvClipInfo();
-
- HRESULT ReadInfo(LPCTSTR strFile);
- Stream* FindStream(SHORT wPID);
- bool IsHdmv() const { return m_bIsHdmv; };
- size_t GetStreamNumber() { return m_Streams.GetCount(); };
- Stream* GetStreamByIndex(size_t nIndex) {return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
-
- HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists);
- HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
- HRESULT ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters);
+ struct Stream {
+ Stream() {
+ memset(this, 0, sizeof(*this));
+ }
+ SHORT m_PID;
+ PES_STREAM_TYPE m_Type;
+ char m_LanguageCode[4];
+ LCID m_LCID;
+
+ // Valid for video types
+ BDVM_VideoFormat m_VideoFormat;
+ BDVM_FrameRate m_FrameRate;
+ BDVM_AspectRatio m_AspectRatio;
+ // Valid for audio types
+ BDVM_ChannelLayout m_ChannelLayout;
+ BDVM_SampleRate m_SampleRate;
+
+ LPCTSTR Format();
+ };
+
+ struct PlaylistItem {
+ CString m_strFileName;
+ REFERENCE_TIME m_rtIn;
+ REFERENCE_TIME m_rtOut;
+
+ REFERENCE_TIME Duration() const {
+ return m_rtOut - m_rtIn;
+ }
+
+ bool operator == (const PlaylistItem& pi) const {
+ return pi.m_strFileName == m_strFileName;
+ }
+ };
+
+ enum PlaylistMarkType {
+ Reserved = 0x00,
+ EntryMark = 0x01,
+ LinkPoint = 0x02
+ };
+
+ struct PlaylistChapter {
+ SHORT m_nPlayItemId;
+ PlaylistMarkType m_nMarkType;
+ REFERENCE_TIME m_rtTimestamp;
+ SHORT m_nEntryPID;
+ REFERENCE_TIME m_rtDuration;
+ };
+
+ CHdmvClipInfo(void);
+ ~CHdmvClipInfo();
+
+ HRESULT ReadInfo(LPCTSTR strFile);
+ Stream* FindStream(SHORT wPID);
+ bool IsHdmv() const { return m_bIsHdmv; };
+ size_t GetStreamNumber() { return m_Streams.GetCount(); };
+ Stream* GetStreamByIndex(size_t nIndex) {return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
+
+ HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists);
+ HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
+ HRESULT ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters);
private :
- DWORD SequenceInfo_start_address;
- DWORD ProgramInfo_start_address;
+ DWORD SequenceInfo_start_address;
+ DWORD ProgramInfo_start_address;
- HANDLE m_hFile;
+ HANDLE m_hFile;
- CAtlArray<Stream> m_Streams;
- bool m_bIsHdmv;
+ CAtlArray<Stream> m_Streams;
+ bool m_bIsHdmv;
- DWORD ReadDword();
- SHORT ReadShort();
- BYTE ReadByte();
- void ReadBuffer(BYTE* pBuff, DWORD nLen);
+ DWORD ReadDword();
+ SHORT ReadShort();
+ BYTE ReadByte();
+ void ReadBuffer(BYTE* pBuff, DWORD nLen);
- HRESULT ReadProgramInfo();
- HRESULT CloseFile(HRESULT hr);
+ HRESULT ReadProgramInfo();
+ HRESULT CloseFile(HRESULT hr);
};
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp
index e34a425f6..36c40d9b2 100644
--- a/src/DSUtil/MediaTypeEx.cpp
+++ b/src/DSUtil/MediaTypeEx.cpp
@@ -31,12 +31,12 @@
#pragma pack(push, 1)
typedef struct {
- WAVEFORMATEX Format;
- BYTE bBigEndian;
- BYTE bsid;
- BYTE lfeon;
- BYTE copyrightb;
- BYTE nAuxBitsCode; // Aux bits per frame
+ WAVEFORMATEX Format;
+ BYTE bBigEndian;
+ BYTE bsid;
+ BYTE lfeon;
+ BYTE copyrightb;
+ BYTE nAuxBitsCode; // Aux bits per frame
} DOLBYAC3WAVEFORMAT;
#pragma pack(pop)
@@ -46,680 +46,681 @@ CMediaTypeEx::CMediaTypeEx()
CString CMediaTypeEx::ToString(IPin* pPin)
{
- CString packing, type, codec, dim, rate, dur;
-
- // TODO
-
- if (majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
- packing = _T("Encrypted MPEG2 Pack");
- } else if (majortype == MEDIATYPE_MPEG2_PACK) {
- packing = _T("MPEG2 Pack");
- } else if (majortype == MEDIATYPE_MPEG2_PES) {
- packing = _T("MPEG2 PES");
- }
-
- if (majortype == MEDIATYPE_Video) {
- type = _T("Video");
-
- BITMAPINFOHEADER bih;
- bool fBIH = ExtractBIH(this, &bih);
-
- int w, h, arx, ary;
- bool fDim = ExtractDim(this, w, h, arx, ary);
-
- if (fBIH) {
- codec = GetVideoCodecName(subtype, bih.biCompression);
- }
-
- if (codec.IsEmpty()) {
- if (formattype == FORMAT_MPEGVideo) {
- codec = _T("MPEG1 Video");
- } else if (formattype == FORMAT_MPEG2_VIDEO) {
- codec = _T("MPEG2 Video");
- } else if (formattype == FORMAT_DiracVideoInfo) {
- codec = _T("Dirac Video");
- }
- }
-
- if (fDim) {
- dim.Format(_T("%dx%d"), w, h);
- if (w*ary != h*arx) {
- dim.AppendFormat(_T(" (%d:%d)"), arx, ary);
- }
- }
-
- if (formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
- if (vih->AvgTimePerFrame) {
- rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
- rate.TrimRight(_T('0')); // remove trailing zeros
- rate.TrimRight(_T('.')); // remove the trailing dot
- rate += _T("fps ");
- }
- if (vih->dwBitRate) {
- rate.AppendFormat(_T("%dkbps"), vih->dwBitRate/1000);
- }
- } else if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat;
- if (vih->AvgTimePerFrame) {
- rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
- rate.TrimRight(_T('0')); // remove trailing zeros
- rate.TrimRight(_T('.')); // remove the trailing dot
- rate += _T("fps ");
- }
- if (vih->dwBitRate) {
- rate.AppendFormat(_T("%dkbps"), vih->dwBitRate/1000);
- }
- }
-
- rate.TrimRight();
-
- if (subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
- type = _T("Subtitle");
- codec = _T("DVD Subpicture");
- }
- } else if (majortype == MEDIATYPE_Audio) {
- type = _T("Audio");
-
- if (formattype == FORMAT_WaveFormatEx) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();
-
- if (wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
- && wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/
- || subtype != GUID_NULL) {
- codec = GetAudioCodecName(subtype, wfe->wFormatTag);
- dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
- if (wfe->nChannels == 1) {
- dim += _T(" mono");
- } else if (wfe->nChannels == 2) {
- dim += _T(" stereo");
- } else {
- dim.AppendFormat(_T(" %dch"), wfe->nChannels);
- }
- if (wfe->nAvgBytesPerSec) {
- rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec*8/1000);
- }
- }
- } else if (formattype == FORMAT_VorbisFormat) {
- VORBISFORMAT* vf = (VORBISFORMAT*)Format();
-
- codec = GetAudioCodecName(subtype, 0);
- dim.Format(_T("%dHz"), vf->nSamplesPerSec);
- if (vf->nChannels == 1) {
- dim += _T(" mono");
- } else if (vf->nChannels == 2) {
- dim += _T(" stereo");
- } else {
- dim.AppendFormat(_T(" %dch"), vf->nChannels);
- }
- if (vf->nAvgBitsPerSec) {
- rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec/1000);
- }
- } else if (formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2* vf = (VORBISFORMAT2*)Format();
-
- codec = GetAudioCodecName(subtype, 0);
- dim.Format(_T("%dHz"), vf->SamplesPerSec);
- if (vf->Channels == 1) {
- dim += _T(" mono");
- } else if (vf->Channels == 2) {
- dim += _T(" stereo");
- } else {
- dim.AppendFormat(_T(" %dch"), vf->Channels);
- }
- }
- } else if (majortype == MEDIATYPE_Text) {
- type = _T("Text");
- } else if (majortype == MEDIATYPE_Subtitle) {
- type = _T("Subtitle");
- codec = GetSubtitleCodecName(subtype);
- } else {
- type = _T("Unknown");
- }
-
- if (CComQIPtr<IMediaSeeking> pMS = pPin) {
- REFERENCE_TIME rtDur = 0;
- if (SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur) {
- rtDur /= 10000000;
- int s = rtDur%60;
- rtDur /= 60;
- int m = rtDur%60;
- rtDur /= 60;
- int h = (int)rtDur;
- if (h) {
- dur.Format(_T("%d:%02d:%02d"), h, m, s);
- } else if (m) {
- dur.Format(_T("%02d:%02d"), m, s);
- } else if (s) {
- dur.Format(_T("%ds"), s);
- }
- }
- }
-
- CString str;
- if (!codec.IsEmpty()) {
- str += codec + _T(" ");
- }
- if (!dim.IsEmpty()) {
- str += dim + _T(" ");
- }
- if (!rate.IsEmpty()) {
- str += rate + _T(" ");
- }
- if (!dur.IsEmpty()) {
- str += dur + _T(" ");
- }
- str.Trim(_T(" ,"));
-
- if (!str.IsEmpty()) {
- str = type + _T(": ") + str;
- } else {
- str = type;
- }
-
- return str;
+ CString packing, type, codec, dim, rate, dur;
+
+ // TODO
+
+ if (majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ packing = _T("Encrypted MPEG2 Pack");
+ } else if (majortype == MEDIATYPE_MPEG2_PACK) {
+ packing = _T("MPEG2 Pack");
+ } else if (majortype == MEDIATYPE_MPEG2_PES) {
+ packing = _T("MPEG2 PES");
+ }
+
+ if (majortype == MEDIATYPE_Video) {
+ type = _T("Video");
+
+ BITMAPINFOHEADER bih;
+ bool fBIH = ExtractBIH(this, &bih);
+
+ int w, h, arx, ary;
+ bool fDim = ExtractDim(this, w, h, arx, ary);
+
+ if (fBIH) {
+ codec = GetVideoCodecName(subtype, bih.biCompression);
+ }
+
+ if (codec.IsEmpty()) {
+ if (formattype == FORMAT_MPEGVideo) {
+ codec = _T("MPEG1 Video");
+ } else if (formattype == FORMAT_MPEG2_VIDEO) {
+ codec = _T("MPEG2 Video");
+ } else if (formattype == FORMAT_DiracVideoInfo) {
+ codec = _T("Dirac Video");
+ }
+ }
+
+ if (fDim) {
+ dim.Format(_T("%dx%d"), w, h);
+ if (w * ary != h * arx) {
+ dim.AppendFormat(_T(" (%d:%d)"), arx, ary);
+ }
+ }
+
+ if (formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
+ if (vih->AvgTimePerFrame) {
+ rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
+ rate.TrimRight(_T('0')); // remove trailing zeros
+ rate.TrimRight(_T('.')); // remove the trailing dot
+ rate += _T("fps ");
+ }
+ if (vih->dwBitRate) {
+ rate.AppendFormat(_T("%dkbps"), vih->dwBitRate / 1000);
+ }
+ } else if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat;
+ if (vih->AvgTimePerFrame) {
+ rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
+ rate.TrimRight(_T('0')); // remove trailing zeros
+ rate.TrimRight(_T('.')); // remove the trailing dot
+ rate += _T("fps ");
+ }
+ if (vih->dwBitRate) {
+ rate.AppendFormat(_T("%dkbps"), vih->dwBitRate / 1000);
+ }
+ }
+
+ rate.TrimRight();
+
+ if (subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
+ type = _T("Subtitle");
+ codec = _T("DVD Subpicture");
+ }
+ } else if (majortype == MEDIATYPE_Audio) {
+ type = _T("Audio");
+
+ if (formattype == FORMAT_WaveFormatEx) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();
+
+ if (wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
+ && wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/
+ || subtype != GUID_NULL) {
+ codec = GetAudioCodecName(subtype, wfe->wFormatTag);
+ dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
+ if (wfe->nChannels == 1) {
+ dim += _T(" mono");
+ } else if (wfe->nChannels == 2) {
+ dim += _T(" stereo");
+ } else {
+ dim.AppendFormat(_T(" %dch"), wfe->nChannels);
+ }
+ if (wfe->nAvgBytesPerSec) {
+ rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec * 8 / 1000);
+ }
+ }
+ } else if (formattype == FORMAT_VorbisFormat) {
+ VORBISFORMAT* vf = (VORBISFORMAT*)Format();
+
+ codec = GetAudioCodecName(subtype, 0);
+ dim.Format(_T("%dHz"), vf->nSamplesPerSec);
+ if (vf->nChannels == 1) {
+ dim += _T(" mono");
+ } else if (vf->nChannels == 2) {
+ dim += _T(" stereo");
+ } else {
+ dim.AppendFormat(_T(" %dch"), vf->nChannels);
+ }
+ if (vf->nAvgBitsPerSec) {
+ rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec / 1000);
+ }
+ } else if (formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2* vf = (VORBISFORMAT2*)Format();
+
+ codec = GetAudioCodecName(subtype, 0);
+ dim.Format(_T("%dHz"), vf->SamplesPerSec);
+ if (vf->Channels == 1) {
+ dim += _T(" mono");
+ } else if (vf->Channels == 2) {
+ dim += _T(" stereo");
+ } else {
+ dim.AppendFormat(_T(" %dch"), vf->Channels);
+ }
+ }
+ } else if (majortype == MEDIATYPE_Text) {
+ type = _T("Text");
+ } else if (majortype == MEDIATYPE_Subtitle) {
+ type = _T("Subtitle");
+ codec = GetSubtitleCodecName(subtype);
+ } else {
+ type = _T("Unknown");
+ }
+
+ if (CComQIPtr<IMediaSeeking> pMS = pPin) {
+ REFERENCE_TIME rtDur = 0;
+ if (SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur) {
+ rtDur /= 10000000;
+ int s = rtDur % 60;
+ rtDur /= 60;
+ int m = rtDur % 60;
+ rtDur /= 60;
+ int h = (int)rtDur;
+ if (h) {
+ dur.Format(_T("%d:%02d:%02d"), h, m, s);
+ } else if (m) {
+ dur.Format(_T("%02d:%02d"), m, s);
+ } else if (s) {
+ dur.Format(_T("%ds"), s);
+ }
+ }
+ }
+
+ CString str;
+ if (!codec.IsEmpty()) {
+ str += codec + _T(" ");
+ }
+ if (!dim.IsEmpty()) {
+ str += dim + _T(" ");
+ }
+ if (!rate.IsEmpty()) {
+ str += rate + _T(" ");
+ }
+ if (!dur.IsEmpty()) {
+ str += dur + _T(" ");
+ }
+ str.Trim(_T(" ,"));
+
+ if (!str.IsEmpty()) {
+ str = type + _T(": ") + str;
+ } else {
+ str = type;
+ }
+
+ return str;
}
CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression)
{
- CString str = _T("");
-
- static CAtlMap<DWORD, CString> names;
-
- if (names.IsEmpty()) {
- names['WMV1'] = _T("Windows Media Video 7");
- names['WMV2'] = _T("Windows Media Video 8");
- names['WMV3'] = _T("Windows Media Video 9");
- names['DIV3'] = _T("DivX 3");
- names['MP43'] = _T("MSMPEG4v3");
- names['MP42'] = _T("MSMPEG4v2");
- names['MP41'] = _T("MSMPEG4v1");
- names['DX50'] = _T("DivX 5");
- names['DIVX'] = _T("DivX 6");
- names['XVID'] = _T("Xvid");
- names['MP4V'] = _T("MPEG4 Video");
- names['AVC1'] = _T("MPEG4 Video (H264)");
- names['H264'] = _T("MPEG4 Video (H264)");
- names['RV10'] = _T("RealVideo 1");
- names['RV20'] = _T("RealVideo 2");
- names['RV30'] = _T("RealVideo 3");
- names['RV40'] = _T("RealVideo 4");
- names['FLV1'] = _T("Flash Video 1");
- names['FLV4'] = _T("Flash Video 4");
- names['VP50'] = _T("On2 VP5");
- names['VP60'] = _T("On2 VP6");
- names['SVQ3'] = _T("SVQ3");
- names['SVQ1'] = _T("SVQ1");
- names['H263'] = _T("H263");
- // names[''] = _T("");
- }
-
- if (biCompression) {
- BYTE* b = (BYTE*)&biCompression;
-
- for (ptrdiff_t i = 0; i < 4; i++)
- if (b[i] >= 'a' && b[i] <= 'z') {
- b[i] = toupper(b[i]);
- }
-
- if (!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
- if (subtype == MEDIASUBTYPE_DiracVideo) {
- str = _T("Dirac Video");
- }
- // else if (subtype == ) str = _T("");
- else if (biCompression < 256) {
- str.Format(_T("%d"), biCompression);
- } else {
- str.Format(_T("%4.4hs"), &biCompression);
- }
- }
- } else {
- if (subtype == MEDIASUBTYPE_RGB32)
- str = _T("RGB32");
- else if (subtype == MEDIASUBTYPE_RGB24)
- str = _T("RGB24");
- else if (subtype == MEDIASUBTYPE_RGB555)
- str = _T("RGB555");
- else if (subtype == MEDIASUBTYPE_RGB565)
- str = _T("RGB565");
- }
-
- return str;
+ CString str = _T("");
+
+ static CAtlMap<DWORD, CString> names;
+
+ if (names.IsEmpty()) {
+ names['WMV1'] = _T("Windows Media Video 7");
+ names['WMV2'] = _T("Windows Media Video 8");
+ names['WMV3'] = _T("Windows Media Video 9");
+ names['DIV3'] = _T("DivX 3");
+ names['MP43'] = _T("MSMPEG4v3");
+ names['MP42'] = _T("MSMPEG4v2");
+ names['MP41'] = _T("MSMPEG4v1");
+ names['DX50'] = _T("DivX 5");
+ names['DIVX'] = _T("DivX 6");
+ names['XVID'] = _T("Xvid");
+ names['MP4V'] = _T("MPEG4 Video");
+ names['AVC1'] = _T("MPEG4 Video (H264)");
+ names['H264'] = _T("MPEG4 Video (H264)");
+ names['RV10'] = _T("RealVideo 1");
+ names['RV20'] = _T("RealVideo 2");
+ names['RV30'] = _T("RealVideo 3");
+ names['RV40'] = _T("RealVideo 4");
+ names['FLV1'] = _T("Flash Video 1");
+ names['FLV4'] = _T("Flash Video 4");
+ names['VP50'] = _T("On2 VP5");
+ names['VP60'] = _T("On2 VP6");
+ names['SVQ3'] = _T("SVQ3");
+ names['SVQ1'] = _T("SVQ1");
+ names['H263'] = _T("H263");
+ // names[''] = _T("");
+ }
+
+ if (biCompression) {
+ BYTE* b = (BYTE*)&biCompression;
+
+ for (ptrdiff_t i = 0; i < 4; i++)
+ if (b[i] >= 'a' && b[i] <= 'z') {
+ b[i] = toupper(b[i]);
+ }
+
+ if (!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
+ if (subtype == MEDIASUBTYPE_DiracVideo) {
+ str = _T("Dirac Video");
+ }
+ // else if (subtype == ) str = _T("");
+ else if (biCompression < 256) {
+ str.Format(_T("%d"), biCompression);
+ } else {
+ str.Format(_T("%4.4hs"), &biCompression);
+ }
+ }
+ } else {
+ if (subtype == MEDIASUBTYPE_RGB32) {
+ str = _T("RGB32");
+ } else if (subtype == MEDIASUBTYPE_RGB24) {
+ str = _T("RGB24");
+ } else if (subtype == MEDIASUBTYPE_RGB555) {
+ str = _T("RGB555");
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
+ str = _T("RGB565");
+ }
+ }
+
+ return str;
}
CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag)
{
- CString str;
-
- static CAtlMap<WORD, CString> names;
-
- if (names.IsEmpty()) {
- names[WAVE_FORMAT_PCM] = _T("PCM");
- names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
- names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
- names[WAVE_FORMAT_ADPCM] = _T("MS ADPCM");
- names[WAVE_FORMAT_ALAW] = _T("aLaw");
- names[WAVE_FORMAT_MULAW] = _T("muLaw");
- names[WAVE_FORMAT_DRM] = _T("DRM");
- names[WAVE_FORMAT_OKI_ADPCM] = _T("OKI ADPCM");
- names[WAVE_FORMAT_DVI_ADPCM] = _T("DVI ADPCM");
- names[WAVE_FORMAT_IMA_ADPCM] = _T("IMA ADPCM");
- names[WAVE_FORMAT_MEDIASPACE_ADPCM] = _T("Mediaspace ADPCM");
- names[WAVE_FORMAT_SIERRA_ADPCM] = _T("Sierra ADPCM");
- names[WAVE_FORMAT_G723_ADPCM] = _T("G723 ADPCM");
- names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM] = _T("Dialogic OKI ADPCM");
- names[WAVE_FORMAT_MEDIAVISION_ADPCM] = _T("Media Vision ADPCM");
- names[WAVE_FORMAT_YAMAHA_ADPCM] = _T("Yamaha ADPCM");
- names[WAVE_FORMAT_DSPGROUP_TRUESPEECH] = _T("DSP Group Truespeech");
- names[WAVE_FORMAT_DOLBY_AC2] = _T("Dolby AC2");
- names[WAVE_FORMAT_GSM610] = _T("GSM610");
- names[WAVE_FORMAT_MSNAUDIO] = _T("MSN Audio");
- names[WAVE_FORMAT_ANTEX_ADPCME] = _T("Antex ADPCME");
- names[WAVE_FORMAT_CS_IMAADPCM] = _T("Crystal Semiconductor IMA ADPCM");
- names[WAVE_FORMAT_ROCKWELL_ADPCM] = _T("Rockwell ADPCM");
- names[WAVE_FORMAT_ROCKWELL_DIGITALK] = _T("Rockwell Digitalk");
- names[WAVE_FORMAT_G721_ADPCM] = _T("G721");
- names[WAVE_FORMAT_G728_CELP] = _T("G728");
- names[WAVE_FORMAT_MSG723] = _T("MSG723");
- names[WAVE_FORMAT_MPEG] = _T("MPEG Audio");
- names[WAVE_FORMAT_MPEGLAYER3] = _T("MPEG Audio Layer 3");
- names[WAVE_FORMAT_LUCENT_G723] = _T("Lucent G723");
- names[WAVE_FORMAT_VOXWARE] = _T("Voxware");
- names[WAVE_FORMAT_G726_ADPCM] = _T("G726");
- names[WAVE_FORMAT_G722_ADPCM] = _T("G722");
- names[WAVE_FORMAT_G729A] = _T("G729A");
- names[WAVE_FORMAT_MEDIASONIC_G723] = _T("MediaSonic G723");
- names[WAVE_FORMAT_ZYXEL_ADPCM] = _T("ZyXEL ADPCM");
- names[WAVE_FORMAT_RHETOREX_ADPCM] = _T("Rhetorex ADPCM");
- names[WAVE_FORMAT_VIVO_G723] = _T("Vivo G723");
- names[WAVE_FORMAT_VIVO_SIREN] = _T("Vivo Siren");
- names[WAVE_FORMAT_DIGITAL_G723] = _T("Digital G723");
- names[WAVE_FORMAT_SANYO_LD_ADPCM] = _T("Sanyo LD ADPCM");
- names[WAVE_FORMAT_CREATIVE_ADPCM] = _T("Creative ADPCM");
- names[WAVE_FORMAT_CREATIVE_FASTSPEECH8] = _T("Creative Fastspeech 8");
- names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
- names[WAVE_FORMAT_UHER_ADPCM] = _T("UHER ADPCM");
- names[WAVE_FORMAT_DOLBY_AC3] = _T("Dolby AC3");
- names[WAVE_FORMAT_DVD_DTS] = _T("DTS");
- names[WAVE_FORMAT_AAC] = _T("AAC");
- names[WAVE_FORMAT_LATM_AAC] = _T("AAC(LATM)");
- names[WAVE_FORMAT_FLAC] = _T("FLAC");
- names[WAVE_FORMAT_TTA1] = _T("TTA");
- names[WAVE_FORMAT_14_4] = _T("RealAudio 14.4");
- names[WAVE_FORMAT_28_8] = _T("RealAudio 28.8");
- names[WAVE_FORMAT_ATRC] = _T("RealAudio ATRC");
- names[WAVE_FORMAT_COOK] = _T("RealAudio COOK");
- names[WAVE_FORMAT_DNET] = _T("RealAudio DNET");
- names[WAVE_FORMAT_RAAC] = _T("RealAudio RAAC");
- names[WAVE_FORMAT_RACP] = _T("RealAudio RACP");
- names[WAVE_FORMAT_SIPR] = _T("RealAudio SIPR");
- names[WAVE_FORMAT_PS2_PCM] = _T("PS2 PCM");
- names[WAVE_FORMAT_PS2_ADPCM] = _T("PS2 ADPCM");
- names[0x0160] = _T("Windows Media Audio");
- names[0x0161] = _T("Windows Media Audio");
- names[0x0162] = _T("Windows Media Audio");
- names[0x0163] = _T("Windows Media Audio");
- names[0x6173] = _T("AMR");
- // names[] = _T("");
- }
-
- if (!names.Lookup(wFormatTag, str)) {
- if (subtype == MEDIASUBTYPE_Vorbis) {
- str = _T("Vorbis (deprecated)");
- } else if (subtype == MEDIASUBTYPE_Vorbis2) {
- str = _T("Vorbis");
- } else if (subtype == MEDIASUBTYPE_MP4A) {
- str = _T("MPEG4 Audio");
- } else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
- str = _T("FLAC (framed)");
- } else if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
- str += _T("Dolby AC3");
- } else if (subtype == MEDIASUBTYPE_DTS) {
- str += _T("DTS");
- } else if (subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
- subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
- subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
- subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL64) {
- str += _T("PCM");
- } else if (subtype == MEDIASUBTYPE_IMA4 ||
- subtype == MEDIASUBTYPE_ADPCM_SWF ||
- subtype == MEDIASUBTYPE_ADPCM_AMV) {
- str += _T("ADPCM");
- } else if (subtype == MEDIASUBTYPE_ALAC) {
- str += _T("Alac");
- } else if (subtype == MEDIASUBTYPE_ALS) {
- str += _T("ALS");
- } else {
- str.Format(_T("0x%04x"), wFormatTag);
- }
- }
-
- if (wFormatTag == WAVE_FORMAT_PCM) {
- if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
- str += _T(" (AC3)");
- } else if (subtype == MEDIASUBTYPE_DTS) {
- str += _T(" (DTS)");
- }
- }
-
- return str;
+ CString str;
+
+ static CAtlMap<WORD, CString> names;
+
+ if (names.IsEmpty()) {
+ names[WAVE_FORMAT_PCM] = _T("PCM");
+ names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
+ names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
+ names[WAVE_FORMAT_ADPCM] = _T("MS ADPCM");
+ names[WAVE_FORMAT_ALAW] = _T("aLaw");
+ names[WAVE_FORMAT_MULAW] = _T("muLaw");
+ names[WAVE_FORMAT_DRM] = _T("DRM");
+ names[WAVE_FORMAT_OKI_ADPCM] = _T("OKI ADPCM");
+ names[WAVE_FORMAT_DVI_ADPCM] = _T("DVI ADPCM");
+ names[WAVE_FORMAT_IMA_ADPCM] = _T("IMA ADPCM");
+ names[WAVE_FORMAT_MEDIASPACE_ADPCM] = _T("Mediaspace ADPCM");
+ names[WAVE_FORMAT_SIERRA_ADPCM] = _T("Sierra ADPCM");
+ names[WAVE_FORMAT_G723_ADPCM] = _T("G723 ADPCM");
+ names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM] = _T("Dialogic OKI ADPCM");
+ names[WAVE_FORMAT_MEDIAVISION_ADPCM] = _T("Media Vision ADPCM");
+ names[WAVE_FORMAT_YAMAHA_ADPCM] = _T("Yamaha ADPCM");
+ names[WAVE_FORMAT_DSPGROUP_TRUESPEECH] = _T("DSP Group Truespeech");
+ names[WAVE_FORMAT_DOLBY_AC2] = _T("Dolby AC2");
+ names[WAVE_FORMAT_GSM610] = _T("GSM610");
+ names[WAVE_FORMAT_MSNAUDIO] = _T("MSN Audio");
+ names[WAVE_FORMAT_ANTEX_ADPCME] = _T("Antex ADPCME");
+ names[WAVE_FORMAT_CS_IMAADPCM] = _T("Crystal Semiconductor IMA ADPCM");
+ names[WAVE_FORMAT_ROCKWELL_ADPCM] = _T("Rockwell ADPCM");
+ names[WAVE_FORMAT_ROCKWELL_DIGITALK] = _T("Rockwell Digitalk");
+ names[WAVE_FORMAT_G721_ADPCM] = _T("G721");
+ names[WAVE_FORMAT_G728_CELP] = _T("G728");
+ names[WAVE_FORMAT_MSG723] = _T("MSG723");
+ names[WAVE_FORMAT_MPEG] = _T("MPEG Audio");
+ names[WAVE_FORMAT_MPEGLAYER3] = _T("MPEG Audio Layer 3");
+ names[WAVE_FORMAT_LUCENT_G723] = _T("Lucent G723");
+ names[WAVE_FORMAT_VOXWARE] = _T("Voxware");
+ names[WAVE_FORMAT_G726_ADPCM] = _T("G726");
+ names[WAVE_FORMAT_G722_ADPCM] = _T("G722");
+ names[WAVE_FORMAT_G729A] = _T("G729A");
+ names[WAVE_FORMAT_MEDIASONIC_G723] = _T("MediaSonic G723");
+ names[WAVE_FORMAT_ZYXEL_ADPCM] = _T("ZyXEL ADPCM");
+ names[WAVE_FORMAT_RHETOREX_ADPCM] = _T("Rhetorex ADPCM");
+ names[WAVE_FORMAT_VIVO_G723] = _T("Vivo G723");
+ names[WAVE_FORMAT_VIVO_SIREN] = _T("Vivo Siren");
+ names[WAVE_FORMAT_DIGITAL_G723] = _T("Digital G723");
+ names[WAVE_FORMAT_SANYO_LD_ADPCM] = _T("Sanyo LD ADPCM");
+ names[WAVE_FORMAT_CREATIVE_ADPCM] = _T("Creative ADPCM");
+ names[WAVE_FORMAT_CREATIVE_FASTSPEECH8] = _T("Creative Fastspeech 8");
+ names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
+ names[WAVE_FORMAT_UHER_ADPCM] = _T("UHER ADPCM");
+ names[WAVE_FORMAT_DOLBY_AC3] = _T("Dolby AC3");
+ names[WAVE_FORMAT_DVD_DTS] = _T("DTS");
+ names[WAVE_FORMAT_AAC] = _T("AAC");
+ names[WAVE_FORMAT_LATM_AAC] = _T("AAC(LATM)");
+ names[WAVE_FORMAT_FLAC] = _T("FLAC");
+ names[WAVE_FORMAT_TTA1] = _T("TTA");
+ names[WAVE_FORMAT_14_4] = _T("RealAudio 14.4");
+ names[WAVE_FORMAT_28_8] = _T("RealAudio 28.8");
+ names[WAVE_FORMAT_ATRC] = _T("RealAudio ATRC");
+ names[WAVE_FORMAT_COOK] = _T("RealAudio COOK");
+ names[WAVE_FORMAT_DNET] = _T("RealAudio DNET");
+ names[WAVE_FORMAT_RAAC] = _T("RealAudio RAAC");
+ names[WAVE_FORMAT_RACP] = _T("RealAudio RACP");
+ names[WAVE_FORMAT_SIPR] = _T("RealAudio SIPR");
+ names[WAVE_FORMAT_PS2_PCM] = _T("PS2 PCM");
+ names[WAVE_FORMAT_PS2_ADPCM] = _T("PS2 ADPCM");
+ names[0x0160] = _T("Windows Media Audio");
+ names[0x0161] = _T("Windows Media Audio");
+ names[0x0162] = _T("Windows Media Audio");
+ names[0x0163] = _T("Windows Media Audio");
+ names[0x6173] = _T("AMR");
+ // names[] = _T("");
+ }
+
+ if (!names.Lookup(wFormatTag, str)) {
+ if (subtype == MEDIASUBTYPE_Vorbis) {
+ str = _T("Vorbis (deprecated)");
+ } else if (subtype == MEDIASUBTYPE_Vorbis2) {
+ str = _T("Vorbis");
+ } else if (subtype == MEDIASUBTYPE_MP4A) {
+ str = _T("MPEG4 Audio");
+ } else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
+ str = _T("FLAC (framed)");
+ } else if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ str += _T("Dolby AC3");
+ } else if (subtype == MEDIASUBTYPE_DTS) {
+ str += _T("DTS");
+ } else if (subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
+ subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
+ subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
+ subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL64) {
+ str += _T("PCM");
+ } else if (subtype == MEDIASUBTYPE_IMA4 ||
+ subtype == MEDIASUBTYPE_ADPCM_SWF ||
+ subtype == MEDIASUBTYPE_ADPCM_AMV) {
+ str += _T("ADPCM");
+ } else if (subtype == MEDIASUBTYPE_ALAC) {
+ str += _T("Alac");
+ } else if (subtype == MEDIASUBTYPE_ALS) {
+ str += _T("ALS");
+ } else {
+ str.Format(_T("0x%04x"), wFormatTag);
+ }
+ }
+
+ if (wFormatTag == WAVE_FORMAT_PCM) {
+ if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ str += _T(" (AC3)");
+ } else if (subtype == MEDIASUBTYPE_DTS) {
+ str += _T(" (DTS)");
+ }
+ }
+
+ return str;
}
CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype)
{
- CString str;
+ CString str;
- static CAtlMap<GUID, CString> names;
+ static CAtlMap<GUID, CString> names;
- if (names.IsEmpty()) {
- names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
- names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
- names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
- names[MEDIASUBTYPE_ASS2] = _T("Advanced SubStation Alpha");
- names[MEDIASUBTYPE_USF] = _T("Universal Subtitle Format");
- names[MEDIASUBTYPE_VOBSUB] = _T("VobSub");
- // names[''] = _T("");
- }
+ if (names.IsEmpty()) {
+ names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
+ names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
+ names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
+ names[MEDIASUBTYPE_ASS2] = _T("Advanced SubStation Alpha");
+ names[MEDIASUBTYPE_USF] = _T("Universal Subtitle Format");
+ names[MEDIASUBTYPE_VOBSUB] = _T("VobSub");
+ // names[''] = _T("");
+ }
- if (names.Lookup(subtype, str)) {
+ if (names.Lookup(subtype, str)) {
- }
+ }
- return str;
+ return str;
}
void CMediaTypeEx::Dump(CAtlList<CString>& sl)
{
- CString str;
-
- sl.RemoveAll();
-
- int fmtsize = 0;
-
- CString major = CStringFromGUID(majortype);
- CString sub = CStringFromGUID(subtype);
- CString format = CStringFromGUID(formattype);
-
- sl.AddTail(ToString() + _T("\n"));
-
- sl.AddTail(_T("AM_MEDIA_TYPE: "));
- str.Format(_T("majortype: %s %s"), CString(GuidNames[majortype]), major);
- sl.AddTail(str);
- str.Format(_T("subtype: %s %s"), CString(GuidNames[subtype]), sub);
- sl.AddTail(str);
- str.Format(_T("formattype: %s %s"), CString(GuidNames[formattype]), format);
- sl.AddTail(str);
- str.Format(_T("bFixedSizeSamples: %d"), bFixedSizeSamples);
- sl.AddTail(str);
- str.Format(_T("bTemporalCompression: %d"), bTemporalCompression);
- sl.AddTail(str);
- str.Format(_T("lSampleSize: %d"), lSampleSize);
- sl.AddTail(str);
- str.Format(_T("cbFormat: %d"), cbFormat);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if (formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
- || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO) {
- fmtsize =
- formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
- formattype == FORMAT_VideoInfo2 ? sizeof(VIDEOINFOHEADER2) :
- formattype == FORMAT_MPEGVideo ? sizeof(MPEG1VIDEOINFO)-1 :
- formattype == FORMAT_MPEG2_VIDEO ? sizeof(MPEG2VIDEOINFO)-4 :
- 0;
-
- VIDEOINFOHEADER& vih = *(VIDEOINFOHEADER*)pbFormat;
- BITMAPINFOHEADER* bih = &vih.bmiHeader;
-
- sl.AddTail(_T("VIDEOINFOHEADER:"));
- str.Format(_T("rcSource: (%d,%d)-(%d,%d)"), vih.rcSource.left, vih.rcSource.top, vih.rcSource.right, vih.rcSource.bottom);
- sl.AddTail(str);
- str.Format(_T("rcTarget: (%d,%d)-(%d,%d)"), vih.rcTarget.left, vih.rcTarget.top, vih.rcTarget.right, vih.rcTarget.bottom);
- sl.AddTail(str);
- str.Format(_T("dwBitRate: %d"), vih.dwBitRate);
- sl.AddTail(str);
- str.Format(_T("dwBitErrorRate: %d"), vih.dwBitErrorRate);
- sl.AddTail(str);
- str.Format(_T("AvgTimePerFrame: %I64d"), vih.AvgTimePerFrame);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO) {
- VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
- bih = &vih.bmiHeader;
-
- sl.AddTail(_T("VIDEOINFOHEADER2:"));
- str.Format(_T("dwInterlaceFlags: 0x%08x"), vih.dwInterlaceFlags);
- sl.AddTail(str);
- str.Format(_T("dwCopyProtectFlags: 0x%08x"), vih.dwCopyProtectFlags);
- sl.AddTail(str);
- str.Format(_T("dwPictAspectRatioX: %d"), vih.dwPictAspectRatioX);
- sl.AddTail(str);
- str.Format(_T("dwPictAspectRatioY: %d"), vih.dwPictAspectRatioY);
- sl.AddTail(str);
- str.Format(_T("dwControlFlags: 0x%08x"), vih.dwControlFlags);
- sl.AddTail(str);
- str.Format(_T("dwReserved2: 0x%08x"), vih.dwReserved2);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- if (formattype == FORMAT_MPEGVideo) {
- MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
-
- sl.AddTail(_T("MPEG1VIDEOINFO:"));
- str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
- sl.AddTail(str);
- str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_MPEG2_VIDEO) {
- MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
-
- sl.AddTail(_T("MPEG2VIDEOINFO:"));
- str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
- sl.AddTail(str);
- str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
- sl.AddTail(str);
- str.Format(_T("dwProfile: 0x%08x"), mvih.dwProfile);
- sl.AddTail(str);
- str.Format(_T("dwLevel: 0x%08x"), mvih.dwLevel);
- sl.AddTail(str);
- str.Format(_T("dwFlags: 0x%08x"), mvih.dwFlags);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- sl.AddTail(_T("BITMAPINFOHEADER:"));
- str.Format(_T("biSize: %d"), bih->biSize);
- sl.AddTail(str);
- str.Format(_T("biWidth: %d"), bih->biWidth);
- sl.AddTail(str);
- str.Format(_T("biHeight: %d"), bih->biHeight);
- sl.AddTail(str);
- str.Format(_T("biPlanes: %d"), bih->biPlanes);
- sl.AddTail(str);
- str.Format(_T("biBitCount: %d"), bih->biBitCount);
- sl.AddTail(str);
- if (bih->biCompression < 256) {
- str.Format(_T("biCompression: %d"), bih->biCompression);
- } else {
- str.Format(_T("biCompression: %4.4hs"), &bih->biCompression);
- }
- sl.AddTail(str);
- str.Format(_T("biSizeImage: %d"), bih->biSizeImage);
- sl.AddTail(str);
- str.Format(_T("biXPelsPerMeter: %d"), bih->biXPelsPerMeter);
- sl.AddTail(str);
- str.Format(_T("biYPelsPerMeter: %d"), bih->biYPelsPerMeter);
- sl.AddTail(str);
- str.Format(_T("biClrUsed: %d"), bih->biClrUsed);
- sl.AddTail(str);
- str.Format(_T("biClrImportant: %d"), bih->biClrImportant);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_WaveFormatEx || formattype == FORMAT_WaveFormatExFFMPEG) {
- WAVEFORMATEX *pWfe = NULL;
- if (formattype == FORMAT_WaveFormatExFFMPEG) {
- fmtsize = sizeof(WAVEFORMATEXFFMPEG);
-
- WAVEFORMATEXFFMPEG *wfeff = (WAVEFORMATEXFFMPEG*)pbFormat;
- pWfe = &wfeff->wfex;
-
- sl.AddTail(_T("WAVEFORMATEXFFMPEG:"));
- str.Format(_T("nCodecId: 0x%04x"), wfeff->nCodecId);
- sl.AddTail(str);
- sl.AddTail(_T(""));
- } else {
- fmtsize = sizeof(WAVEFORMATEX);
- pWfe = (WAVEFORMATEX*)pbFormat;
- }
-
- WAVEFORMATEX& wfe = *pWfe;
-
- sl.AddTail(_T("WAVEFORMATEX:"));
- str.Format(_T("wFormatTag: 0x%04x"), wfe.wFormatTag);
- sl.AddTail(str);
- str.Format(_T("nChannels: %d"), wfe.nChannels);
- sl.AddTail(str);
- str.Format(_T("nSamplesPerSec: %d"), wfe.nSamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("nAvgBytesPerSec: %d"), wfe.nAvgBytesPerSec);
- sl.AddTail(str);
- str.Format(_T("nBlockAlign: %d"), wfe.nBlockAlign);
- sl.AddTail(str);
- str.Format(_T("wBitsPerSample: %d"), wfe.wBitsPerSample);
- sl.AddTail(str);
- str.Format(_T("cbSize: %d (extra bytes)"), wfe.cbSize);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if (wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0 && formattype == FORMAT_WaveFormatEx) {
- if (wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX)) {
- fmtsize = sizeof(WAVEFORMATEXTENSIBLE);
-
- WAVEFORMATEXTENSIBLE& wfe = *(WAVEFORMATEXTENSIBLE*)pbFormat;
-
- sl.AddTail(_T("WAVEFORMATEXTENSIBLE:"));
- if (wfe.Format.wBitsPerSample != 0) {
- str.Format(_T("wValidBitsPerSample: %d"), wfe.Samples.wValidBitsPerSample);
- } else {
- str.Format(_T("wSamplesPerBlock: %d"), wfe.Samples.wSamplesPerBlock);
- }
- sl.AddTail(str);
- str.Format(_T("dwChannelMask: 0x%08x"), wfe.dwChannelMask);
- sl.AddTail(str);
- str.Format(_T("SubFormat: %s"), CStringFromGUID(wfe.SubFormat));
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX)) {
- fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
-
- DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
-
- sl.AddTail(_T("DOLBYAC3WAVEFORMAT:"));
- str.Format(_T("bBigEndian: %d"), wfe.bBigEndian);
- sl.AddTail(str);
- str.Format(_T("bsid: %d"), wfe.bsid);
- sl.AddTail(str);
- str.Format(_T("lfeon: %d"), wfe.lfeon);
- sl.AddTail(str);
- str.Format(_T("copyrightb: %d"), wfe.copyrightb);
- sl.AddTail(str);
- str.Format(_T("nAuxBitsCode: %d"), wfe.nAuxBitsCode);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- }
- } else if (formattype == FORMAT_VorbisFormat) {
- fmtsize = sizeof(VORBISFORMAT);
-
- VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
-
- sl.AddTail(_T("VORBISFORMAT:"));
- str.Format(_T("nChannels: %d"), vf.nChannels);
- sl.AddTail(str);
- str.Format(_T("nSamplesPerSec: %d"), vf.nSamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("nMinBitsPerSec: %d"), vf.nMinBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("nAvgBitsPerSec: %d"), vf.nAvgBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("nMaxBitsPerSec: %d"), vf.nMaxBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("fQuality: %.3f"), vf.fQuality);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_VorbisFormat2) {
- fmtsize = sizeof(VORBISFORMAT2);
-
- VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
-
- sl.AddTail(_T("VORBISFORMAT:"));
- str.Format(_T("Channels: %d"), vf.Channels);
- sl.AddTail(str);
- str.Format(_T("SamplesPerSec: %d"), vf.SamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("BitsPerSample: %d"), vf.BitsPerSample);
- sl.AddTail(str);
- str.Format(_T("HeaderSize: {%d, %d, %d}"), vf.HeaderSize[0], vf.HeaderSize[1], vf.HeaderSize[2]);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_SubtitleInfo) {
- fmtsize = sizeof(SUBTITLEINFO);
-
- SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
-
- sl.AddTail(_T("SUBTITLEINFO:"));
- str.Format(_T("dwOffset: %d"), si.dwOffset);
- sl.AddTail(str);
- str.Format(_T("IsoLang: %s"), CString(CStringA(si.IsoLang, sizeof(si.IsoLang)-1)));
- sl.AddTail(str);
- str.Format(_T("TrackName: %s"), CString(CStringW(si.TrackName, sizeof(si.TrackName)-1)));
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- if (cbFormat > 0) {
- sl.AddTail(_T("pbFormat:"));
-
- for (ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16) {
- str.Format(_T("%04x:"), i);
-
- for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
- CString byte;
- byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
- str += byte;
- }
-
- for (ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++) {
- str += _T(" ");
- }
-
- str += ' ';
-
- for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
- unsigned char c = (unsigned char)pbFormat[k];
- CStringA ch;
- ch.Format("%c", c >= 0x20 ? c : '.');
- str += ch;
- }
-
- sl.AddTail(str);
- }
-
- sl.AddTail(_T(""));
- }
+ CString str;
+
+ sl.RemoveAll();
+
+ int fmtsize = 0;
+
+ CString major = CStringFromGUID(majortype);
+ CString sub = CStringFromGUID(subtype);
+ CString format = CStringFromGUID(formattype);
+
+ sl.AddTail(ToString() + _T("\n"));
+
+ sl.AddTail(_T("AM_MEDIA_TYPE: "));
+ str.Format(_T("majortype: %s %s"), CString(GuidNames[majortype]), major);
+ sl.AddTail(str);
+ str.Format(_T("subtype: %s %s"), CString(GuidNames[subtype]), sub);
+ sl.AddTail(str);
+ str.Format(_T("formattype: %s %s"), CString(GuidNames[formattype]), format);
+ sl.AddTail(str);
+ str.Format(_T("bFixedSizeSamples: %d"), bFixedSizeSamples);
+ sl.AddTail(str);
+ str.Format(_T("bTemporalCompression: %d"), bTemporalCompression);
+ sl.AddTail(str);
+ str.Format(_T("lSampleSize: %d"), lSampleSize);
+ sl.AddTail(str);
+ str.Format(_T("cbFormat: %d"), cbFormat);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if (formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
+ || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO) {
+ fmtsize =
+ formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
+ formattype == FORMAT_VideoInfo2 ? sizeof(VIDEOINFOHEADER2) :
+ formattype == FORMAT_MPEGVideo ? sizeof(MPEG1VIDEOINFO) - 1 :
+ formattype == FORMAT_MPEG2_VIDEO ? sizeof(MPEG2VIDEOINFO) - 4 :
+ 0;
+
+ VIDEOINFOHEADER& vih = *(VIDEOINFOHEADER*)pbFormat;
+ BITMAPINFOHEADER* bih = &vih.bmiHeader;
+
+ sl.AddTail(_T("VIDEOINFOHEADER:"));
+ str.Format(_T("rcSource: (%d,%d)-(%d,%d)"), vih.rcSource.left, vih.rcSource.top, vih.rcSource.right, vih.rcSource.bottom);
+ sl.AddTail(str);
+ str.Format(_T("rcTarget: (%d,%d)-(%d,%d)"), vih.rcTarget.left, vih.rcTarget.top, vih.rcTarget.right, vih.rcTarget.bottom);
+ sl.AddTail(str);
+ str.Format(_T("dwBitRate: %d"), vih.dwBitRate);
+ sl.AddTail(str);
+ str.Format(_T("dwBitErrorRate: %d"), vih.dwBitErrorRate);
+ sl.AddTail(str);
+ str.Format(_T("AvgTimePerFrame: %I64d"), vih.AvgTimePerFrame);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO) {
+ VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
+ bih = &vih.bmiHeader;
+
+ sl.AddTail(_T("VIDEOINFOHEADER2:"));
+ str.Format(_T("dwInterlaceFlags: 0x%08x"), vih.dwInterlaceFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwCopyProtectFlags: 0x%08x"), vih.dwCopyProtectFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwPictAspectRatioX: %d"), vih.dwPictAspectRatioX);
+ sl.AddTail(str);
+ str.Format(_T("dwPictAspectRatioY: %d"), vih.dwPictAspectRatioY);
+ sl.AddTail(str);
+ str.Format(_T("dwControlFlags: 0x%08x"), vih.dwControlFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwReserved2: 0x%08x"), vih.dwReserved2);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ if (formattype == FORMAT_MPEGVideo) {
+ MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
+
+ sl.AddTail(_T("MPEG1VIDEOINFO:"));
+ str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
+ sl.AddTail(str);
+ str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_MPEG2_VIDEO) {
+ MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
+
+ sl.AddTail(_T("MPEG2VIDEOINFO:"));
+ str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
+ sl.AddTail(str);
+ str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
+ sl.AddTail(str);
+ str.Format(_T("dwProfile: 0x%08x"), mvih.dwProfile);
+ sl.AddTail(str);
+ str.Format(_T("dwLevel: 0x%08x"), mvih.dwLevel);
+ sl.AddTail(str);
+ str.Format(_T("dwFlags: 0x%08x"), mvih.dwFlags);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ sl.AddTail(_T("BITMAPINFOHEADER:"));
+ str.Format(_T("biSize: %d"), bih->biSize);
+ sl.AddTail(str);
+ str.Format(_T("biWidth: %d"), bih->biWidth);
+ sl.AddTail(str);
+ str.Format(_T("biHeight: %d"), bih->biHeight);
+ sl.AddTail(str);
+ str.Format(_T("biPlanes: %d"), bih->biPlanes);
+ sl.AddTail(str);
+ str.Format(_T("biBitCount: %d"), bih->biBitCount);
+ sl.AddTail(str);
+ if (bih->biCompression < 256) {
+ str.Format(_T("biCompression: %d"), bih->biCompression);
+ } else {
+ str.Format(_T("biCompression: %4.4hs"), &bih->biCompression);
+ }
+ sl.AddTail(str);
+ str.Format(_T("biSizeImage: %d"), bih->biSizeImage);
+ sl.AddTail(str);
+ str.Format(_T("biXPelsPerMeter: %d"), bih->biXPelsPerMeter);
+ sl.AddTail(str);
+ str.Format(_T("biYPelsPerMeter: %d"), bih->biYPelsPerMeter);
+ sl.AddTail(str);
+ str.Format(_T("biClrUsed: %d"), bih->biClrUsed);
+ sl.AddTail(str);
+ str.Format(_T("biClrImportant: %d"), bih->biClrImportant);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_WaveFormatEx || formattype == FORMAT_WaveFormatExFFMPEG) {
+ WAVEFORMATEX* pWfe = NULL;
+ if (formattype == FORMAT_WaveFormatExFFMPEG) {
+ fmtsize = sizeof(WAVEFORMATEXFFMPEG);
+
+ WAVEFORMATEXFFMPEG* wfeff = (WAVEFORMATEXFFMPEG*)pbFormat;
+ pWfe = &wfeff->wfex;
+
+ sl.AddTail(_T("WAVEFORMATEXFFMPEG:"));
+ str.Format(_T("nCodecId: 0x%04x"), wfeff->nCodecId);
+ sl.AddTail(str);
+ sl.AddTail(_T(""));
+ } else {
+ fmtsize = sizeof(WAVEFORMATEX);
+ pWfe = (WAVEFORMATEX*)pbFormat;
+ }
+
+ WAVEFORMATEX& wfe = *pWfe;
+
+ sl.AddTail(_T("WAVEFORMATEX:"));
+ str.Format(_T("wFormatTag: 0x%04x"), wfe.wFormatTag);
+ sl.AddTail(str);
+ str.Format(_T("nChannels: %d"), wfe.nChannels);
+ sl.AddTail(str);
+ str.Format(_T("nSamplesPerSec: %d"), wfe.nSamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nAvgBytesPerSec: %d"), wfe.nAvgBytesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nBlockAlign: %d"), wfe.nBlockAlign);
+ sl.AddTail(str);
+ str.Format(_T("wBitsPerSample: %d"), wfe.wBitsPerSample);
+ sl.AddTail(str);
+ str.Format(_T("cbSize: %d (extra bytes)"), wfe.cbSize);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if (wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0 && formattype == FORMAT_WaveFormatEx) {
+ if (wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)) {
+ fmtsize = sizeof(WAVEFORMATEXTENSIBLE);
+
+ WAVEFORMATEXTENSIBLE& wfe = *(WAVEFORMATEXTENSIBLE*)pbFormat;
+
+ sl.AddTail(_T("WAVEFORMATEXTENSIBLE:"));
+ if (wfe.Format.wBitsPerSample != 0) {
+ str.Format(_T("wValidBitsPerSample: %d"), wfe.Samples.wValidBitsPerSample);
+ } else {
+ str.Format(_T("wSamplesPerBlock: %d"), wfe.Samples.wSamplesPerBlock);
+ }
+ sl.AddTail(str);
+ str.Format(_T("dwChannelMask: 0x%08x"), wfe.dwChannelMask);
+ sl.AddTail(str);
+ str.Format(_T("SubFormat: %s"), CStringFromGUID(wfe.SubFormat));
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT) - sizeof(WAVEFORMATEX)) {
+ fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
+
+ DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
+
+ sl.AddTail(_T("DOLBYAC3WAVEFORMAT:"));
+ str.Format(_T("bBigEndian: %d"), wfe.bBigEndian);
+ sl.AddTail(str);
+ str.Format(_T("bsid: %d"), wfe.bsid);
+ sl.AddTail(str);
+ str.Format(_T("lfeon: %d"), wfe.lfeon);
+ sl.AddTail(str);
+ str.Format(_T("copyrightb: %d"), wfe.copyrightb);
+ sl.AddTail(str);
+ str.Format(_T("nAuxBitsCode: %d"), wfe.nAuxBitsCode);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+ }
+ } else if (formattype == FORMAT_VorbisFormat) {
+ fmtsize = sizeof(VORBISFORMAT);
+
+ VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
+
+ sl.AddTail(_T("VORBISFORMAT:"));
+ str.Format(_T("nChannels: %d"), vf.nChannels);
+ sl.AddTail(str);
+ str.Format(_T("nSamplesPerSec: %d"), vf.nSamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nMinBitsPerSec: %d"), vf.nMinBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nAvgBitsPerSec: %d"), vf.nAvgBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nMaxBitsPerSec: %d"), vf.nMaxBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("fQuality: %.3f"), vf.fQuality);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_VorbisFormat2) {
+ fmtsize = sizeof(VORBISFORMAT2);
+
+ VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
+
+ sl.AddTail(_T("VORBISFORMAT:"));
+ str.Format(_T("Channels: %d"), vf.Channels);
+ sl.AddTail(str);
+ str.Format(_T("SamplesPerSec: %d"), vf.SamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("BitsPerSample: %d"), vf.BitsPerSample);
+ sl.AddTail(str);
+ str.Format(_T("HeaderSize: {%d, %d, %d}"), vf.HeaderSize[0], vf.HeaderSize[1], vf.HeaderSize[2]);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_SubtitleInfo) {
+ fmtsize = sizeof(SUBTITLEINFO);
+
+ SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
+
+ sl.AddTail(_T("SUBTITLEINFO:"));
+ str.Format(_T("dwOffset: %d"), si.dwOffset);
+ sl.AddTail(str);
+ str.Format(_T("IsoLang: %s"), CString(CStringA(si.IsoLang, sizeof(si.IsoLang) - 1)));
+ sl.AddTail(str);
+ str.Format(_T("TrackName: %s"), CString(CStringW(si.TrackName, sizeof(si.TrackName) - 1)));
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ if (cbFormat > 0) {
+ sl.AddTail(_T("pbFormat:"));
+
+ for (ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16) {
+ str.Format(_T("%04x:"), i);
+
+ for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
+ CString byte;
+ byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
+ str += byte;
+ }
+
+ for (ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++) {
+ str += _T(" ");
+ }
+
+ str += ' ';
+
+ for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
+ unsigned char c = (unsigned char)pbFormat[k];
+ CStringA ch;
+ ch.Format("%c", c >= 0x20 ? c : '.');
+ str += ch;
+ }
+
+ sl.AddTail(str);
+ }
+
+ sl.AddTail(_T(""));
+ }
}
diff --git a/src/DSUtil/MediaTypeEx.h b/src/DSUtil/MediaTypeEx.h
index 6e79756c5..bf9d09449 100644
--- a/src/DSUtil/MediaTypeEx.h
+++ b/src/DSUtil/MediaTypeEx.h
@@ -26,16 +26,16 @@
class CMediaTypeEx : public CMediaType
{
public:
- CMediaTypeEx();
- CMediaTypeEx(const CMediaType& mt) {
- CMediaType::operator = (mt);
- }
+ CMediaTypeEx();
+ CMediaTypeEx(const CMediaType& mt) {
+ CMediaType::operator = (mt);
+ }
- CString ToString(IPin* pPin = NULL);
+ CString ToString(IPin* pPin = NULL);
- static CString GetVideoCodecName(const GUID& subtype, DWORD biCompression);
- static CString GetAudioCodecName(const GUID& subtype, WORD wFormatTag);
- static CString GetSubtitleCodecName(const GUID& subtype);
+ static CString GetVideoCodecName(const GUID& subtype, DWORD biCompression);
+ static CString GetAudioCodecName(const GUID& subtype, WORD wFormatTag);
+ static CString GetSubtitleCodecName(const GUID& subtype);
- void Dump(CAtlList<CString>& sl);
+ void Dump(CAtlList<CString>& sl);
};
diff --git a/src/DSUtil/MediaTypes.cpp b/src/DSUtil/MediaTypes.cpp
index bd0004d15..f01b69918 100644
--- a/src/DSUtil/MediaTypes.cpp
+++ b/src/DSUtil/MediaTypes.cpp
@@ -34,353 +34,353 @@
#define BIH_SIZE (sizeof(BITMAPINFOHEADER))
VIH vihs[] = {
- // YUY2
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_YUY2 // subtype
- },
- // YV12
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_YV12 // subtype
- },
- // I420
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_I420 // subtype
- },
- // IYUV
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_IYUV // subtype
- },
- // 8888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // 8888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // A888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // A888 bitf (I'm not sure if this exist...)
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // 888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 565 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 565 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xF800, 0x07E0, 0x001F}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 555 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
- // 555 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0x7C00, 0x03E0, 0x001F}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
+ // YUY2
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y', 'U', 'Y', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_YUY2 // subtype
+ },
+ // YV12
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y', 'V', '1', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_YV12 // subtype
+ },
+ // I420
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', '4', '2', '0'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_I420 // subtype
+ },
+ // IYUV
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', 'Y', 'U', 'V'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_IYUV // subtype
+ },
+ // 8888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // 8888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // A888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // A888 bitf (I'm not sure if this exist...)
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // 888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 565 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 565 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xF800, 0x07E0, 0x001F}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 555 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
+ // 555 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0x7C00, 0x03E0, 0x001F}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
};
VIH2 vih2s[] = {
- // YUY2
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_YUY2 // subtype
- },
- // YV12
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_YV12 // subtype
- },
- // I420
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_I420 // subtype
- },
- // IYUV
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_IYUV // subtype
- },
- // 8888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // 8888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // A888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // A888 bitf (I'm not sure if this exist...)
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // 888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 565 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 565 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xF800, 0x07E0, 0x001F}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 555 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
- // 555 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0x7C00, 0x03E0, 0x001F}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
+ // YUY2
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y', 'U', 'Y', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_YUY2 // subtype
+ },
+ // YV12
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y', 'V', '1', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_YV12 // subtype
+ },
+ // I420
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', '4', '2', '0'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_I420 // subtype
+ },
+ // IYUV
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', 'Y', 'U', 'V'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_IYUV // subtype
+ },
+ // 8888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // 8888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // A888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // A888 bitf (I'm not sure if this exist...)
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // 888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 565 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 565 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xF800, 0x07E0, 0x001F}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 555 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
+ // 555 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0x7C00, 0x03E0, 0x001F}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
};
UINT VIHSIZE = _countof(vihs);
CString VIH2String(int i)
{
- CString ret = CString(GuidNames[*vihs[i].subtype]);
- if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
- ret = ret.Mid(13);
- }
- if (vihs[i].vih.bmiHeader.biCompression == 3) {
- ret += _T(" BITF");
- }
- if (*vihs[i].subtype == MEDIASUBTYPE_I420) {
- ret = _T("I420"); // FIXME
- }
- return ret;
+ CString ret = CString(GuidNames[*vihs[i].subtype]);
+ if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
+ ret = ret.Mid(13);
+ }
+ if (vihs[i].vih.bmiHeader.biCompression == 3) {
+ ret += _T(" BITF");
+ }
+ if (*vihs[i].subtype == MEDIASUBTYPE_I420) {
+ ret = _T("I420"); // FIXME
+ }
+ return ret;
}
CString Subtype2String(const GUID& subtype)
{
- CString ret = CString(GuidNames[subtype]);
- if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
- ret = ret.Mid(13);
- }
- if (subtype == MEDIASUBTYPE_I420) {
- ret = _T("I420"); // FIXME
- }
- return ret;
+ CString ret = CString(GuidNames[subtype]);
+ if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
+ ret = ret.Mid(13);
+ }
+ if (subtype == MEDIASUBTYPE_I420) {
+ ret = _T("I420"); // FIXME
+ }
+ return ret;
}
void CorrectMediaType(AM_MEDIA_TYPE* pmt)
{
- if (!pmt) {
- return;
- }
+ if (!pmt) {
+ return;
+ }
- CMediaType mt(*pmt);
+ CMediaType mt(*pmt);
- if (mt.formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
+ if (mt.formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- for (UINT i = 0; i < VIHSIZE; i++) {
- if (mt.subtype == *vihs[i].subtype
- && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression) {
- mt.AllocFormatBuffer(vihs[i].size);
- memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
- memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER));
- break;
- }
- }
- } else if (mt.formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
+ for (UINT i = 0; i < VIHSIZE; i++) {
+ if (mt.subtype == *vihs[i].subtype
+ && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression) {
+ mt.AllocFormatBuffer(vihs[i].size);
+ memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
+ memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER));
+ break;
+ }
+ }
+ } else if (mt.formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- for (UINT i = 0; i < VIHSIZE; i++) {
- if (mt.subtype == *vih2s[i].subtype
- && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression) {
- mt.AllocFormatBuffer(vih2s[i].size);
- memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
- memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER2));
- break;
- }
- }
- }
+ for (UINT i = 0; i < VIHSIZE; i++) {
+ if (mt.subtype == *vih2s[i].subtype
+ && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression) {
+ mt.AllocFormatBuffer(vih2s[i].size);
+ memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
+ memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER2));
+ break;
+ }
+ }
+ }
- CopyMediaType(pmt, &mt);
+ CopyMediaType(pmt, &mt);
}
diff --git a/src/DSUtil/MediaTypes.h b/src/DSUtil/MediaTypes.h
index d08e0d3ba..784f574ee 100644
--- a/src/DSUtil/MediaTypes.h
+++ b/src/DSUtil/MediaTypes.h
@@ -25,17 +25,17 @@
#pragma pack(1)
struct VIH {
- VIDEOINFOHEADER vih;
- UINT mask[3];
- int size;
- const GUID* subtype;
+ VIDEOINFOHEADER vih;
+ UINT mask[3];
+ int size;
+ const GUID* subtype;
};
struct VIH2 {
- VIDEOINFOHEADER2 vih;
- UINT mask[3];
- int size;
- const GUID* subtype;
+ VIDEOINFOHEADER2 vih;
+ UINT mask[3];
+ int size;
+ const GUID* subtype;
};
#pragma pack()
diff --git a/src/DSUtil/Mpeg2Def.h b/src/DSUtil/Mpeg2Def.h
index 886c949b1..97e77f58c 100644
--- a/src/DSUtil/Mpeg2Def.h
+++ b/src/DSUtil/Mpeg2Def.h
@@ -23,142 +23,142 @@
#pragma once
enum PES_STREAM_TYPE {
- INVALID = 0,
- VIDEO_STREAM_MPEG1 = 0x01,
- VIDEO_STREAM_MPEG2 = 0x02, // ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
- AUDIO_STREAM_MPEG1 = 0x03, // all layers including mp3 (ISO/IEC 11172-3 Audio)
- AUDIO_STREAM_MPEG2 = 0x04, // ISO/IEC 13818-3 Audio
- PRIVATE = 0x05, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
- PES_PRIVATE = 0x06, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
- PES_07 = 0x07, // ISO/IEC 13522 MHEG
- PES_08 = 0x08, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
- PES_09 = 0x09, // ITU-T Rec. H.222.1
- PES_0a = 0x0a, // ISO/IEC 13818-6 type A
- PES_0b = 0x0b, // ISO/IEC 13818-6 type B
- PES_0c = 0x0c, // ISO/IEC 13818-6 type C
- PES_0d = 0x0d, // ISO/IEC 13818-6 type D
- PES_0e = 0x0e, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
- AUDIO_STREAM_AAC = 0x0f, // ISO/IEC 13818-7 Audio with ADTS transport syntax
- PES_10 = 0x10, // ISO/IEC 14496-2 Visual
- AUDIO_STREAM_AAC_LATM = 0x11, // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1
- PES_12 = 0x12, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
- PES_13 = 0x13, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.
- PES_14 = 0x14, // ISO/IEC 13818-6 Synchronized Download Protocol
- METADATA_PES_PACKETS = 0x15, // Metadata carried in PES packets
- METADATA_SECTIONS = 0X16, // Metadata carried in metadata_sections
- DATA_CAROUSEL = 0x17, // Metadata carried in ISO/IEC 13818-6 Data Carousel
- OBJECT_CAROUSEL = 0x18, // Metadata carried in ISO/IEC 13818-6 Object Carousel
- SYNCHRONIZED_DOWNLOAD = 0x19, // Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol
- IPMP = 0x1A, // IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
- VIDEO_STREAM_H264 = 0x1B, // AVC video stream conforming to one or more profiles defined in Annex A of ITU-T Rec. H.264
- PES_1C = 0x1C, // ISO/IEC 14496-3 Audio, without using any additional transport syntax, such as DST, ALS and SLS
- TEXT = 0x1D, // ISO/IEC 14496-17 Text
- AUXILIARY_VIDEO_STREAM = 0x1E, // Auxiliary video stream as defined in ISO/IEC 23002-3
- SVC_H264 = 0x1F, // SVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex G of ITU-T Rec. H.264 | ISO/IEC 14496-10
- MVC_H264 = 0x20, // MVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex H of ITU-T Rec. H.264 | ISO/IEC 14496-10
- AUDIO_STREAM_LPCM = 0x80,
- AUDIO_STREAM_AC3 = 0x81,
- AUDIO_STREAM_DTS = 0x82,
- AUDIO_STREAM_AC3_TRUE_HD = 0x83,
- AUDIO_STREAM_AC3_PLUS = 0x84,
- AUDIO_STREAM_DTS_HD = 0x85,
- AUDIO_STREAM_DTS_HD_MASTER_AUDIO = 0x86,
- PRESENTATION_GRAPHICS_STREAM = 0x90,
- INTERACTIVE_GRAPHICS_STREAM = 0x91,
- SUBTITLE_STREAM = 0x92,
- SECONDARY_AUDIO_AC3_PLUS = 0xa1,
- SECONDARY_AUDIO_DTS_HD = 0xa2,
- VIDEO_STREAM_VC1 = 0xea
+ INVALID = 0,
+ VIDEO_STREAM_MPEG1 = 0x01,
+ VIDEO_STREAM_MPEG2 = 0x02, // ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
+ AUDIO_STREAM_MPEG1 = 0x03, // all layers including mp3 (ISO/IEC 11172-3 Audio)
+ AUDIO_STREAM_MPEG2 = 0x04, // ISO/IEC 13818-3 Audio
+ PRIVATE = 0x05, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
+ PES_PRIVATE = 0x06, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
+ PES_07 = 0x07, // ISO/IEC 13522 MHEG
+ PES_08 = 0x08, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
+ PES_09 = 0x09, // ITU-T Rec. H.222.1
+ PES_0a = 0x0a, // ISO/IEC 13818-6 type A
+ PES_0b = 0x0b, // ISO/IEC 13818-6 type B
+ PES_0c = 0x0c, // ISO/IEC 13818-6 type C
+ PES_0d = 0x0d, // ISO/IEC 13818-6 type D
+ PES_0e = 0x0e, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
+ AUDIO_STREAM_AAC = 0x0f, // ISO/IEC 13818-7 Audio with ADTS transport syntax
+ PES_10 = 0x10, // ISO/IEC 14496-2 Visual
+ AUDIO_STREAM_AAC_LATM = 0x11, // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1
+ PES_12 = 0x12, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
+ PES_13 = 0x13, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.
+ PES_14 = 0x14, // ISO/IEC 13818-6 Synchronized Download Protocol
+ METADATA_PES_PACKETS = 0x15, // Metadata carried in PES packets
+ METADATA_SECTIONS = 0X16, // Metadata carried in metadata_sections
+ DATA_CAROUSEL = 0x17, // Metadata carried in ISO/IEC 13818-6 Data Carousel
+ OBJECT_CAROUSEL = 0x18, // Metadata carried in ISO/IEC 13818-6 Object Carousel
+ SYNCHRONIZED_DOWNLOAD = 0x19, // Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol
+ IPMP = 0x1A, // IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
+ VIDEO_STREAM_H264 = 0x1B, // AVC video stream conforming to one or more profiles defined in Annex A of ITU-T Rec. H.264
+ PES_1C = 0x1C, // ISO/IEC 14496-3 Audio, without using any additional transport syntax, such as DST, ALS and SLS
+ TEXT = 0x1D, // ISO/IEC 14496-17 Text
+ AUXILIARY_VIDEO_STREAM = 0x1E, // Auxiliary video stream as defined in ISO/IEC 23002-3
+ SVC_H264 = 0x1F, // SVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex G of ITU-T Rec. H.264 | ISO/IEC 14496-10
+ MVC_H264 = 0x20, // MVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex H of ITU-T Rec. H.264 | ISO/IEC 14496-10
+ AUDIO_STREAM_LPCM = 0x80,
+ AUDIO_STREAM_AC3 = 0x81,
+ AUDIO_STREAM_DTS = 0x82,
+ AUDIO_STREAM_AC3_TRUE_HD = 0x83,
+ AUDIO_STREAM_AC3_PLUS = 0x84,
+ AUDIO_STREAM_DTS_HD = 0x85,
+ AUDIO_STREAM_DTS_HD_MASTER_AUDIO = 0x86,
+ PRESENTATION_GRAPHICS_STREAM = 0x90,
+ INTERACTIVE_GRAPHICS_STREAM = 0x91,
+ SUBTITLE_STREAM = 0x92,
+ SECONDARY_AUDIO_AC3_PLUS = 0xa1,
+ SECONDARY_AUDIO_DTS_HD = 0xa2,
+ VIDEO_STREAM_VC1 = 0xea
};
enum MPEG2_PID {
- PID_PAT = 0x000, // Program Association Table
- PID_CAT = 0x001, // Conditional Access Table
- PID_TSDT = 0x002, // Transport Stream Description Table
- PID_NIT = 0x010, // Network Identification Table
- PID_BAT = 0x011, // Bouquet Association Table ou ...
- PID_SDT = 0x011, // Service Description Table
- PID_EIT = 0x012, // Event Information Table
- PID_RST = 0x013, // Running Status Tection
- PID_TDT = 0x014, // Time and Date Table ou ...
- PID_TOT = 0x014, // Time Offset Table
- PID_SFN = 0x015, // SFN/MIP synchronisation
- PID_DIT = 0x01e,
- PID_SIT = 0x01f,
- PID_NULL = 0x1fff // Null packet
+ PID_PAT = 0x000, // Program Association Table
+ PID_CAT = 0x001, // Conditional Access Table
+ PID_TSDT = 0x002, // Transport Stream Description Table
+ PID_NIT = 0x010, // Network Identification Table
+ PID_BAT = 0x011, // Bouquet Association Table ou ...
+ PID_SDT = 0x011, // Service Description Table
+ PID_EIT = 0x012, // Event Information Table
+ PID_RST = 0x013, // Running Status Tection
+ PID_TDT = 0x014, // Time and Date Table ou ...
+ PID_TOT = 0x014, // Time Offset Table
+ PID_SFN = 0x015, // SFN/MIP synchronisation
+ PID_DIT = 0x01e,
+ PID_SIT = 0x01f,
+ PID_NULL = 0x1fff // Null packet
};
enum DVB_SI {
- SI_undef = -1,
- SI_PAT = 0x00,
- SI_CAT = 0x01,
- SI_PMT = 0x02,
- SI_DSMCC_a = 0x3a,
- SI_DSMCC_b = 0x3b,
- SI_DSMCC_c = 0x3c,
- SI_DSMCC_d = 0x3d,
- SI_DSMCC_e = 0x3e,
- SI_DSMCC_f = 0x3f,
- SI_NIT = 0x40,
- SI_SDT = 0x42,
- SI_EIT_act = 0x4e,
- SI_EIT_oth = 0x4f,
- SI_EIT_as0, SI_EIT_as1, SI_EIT_as2, SI_EIT_as3, SI_EIT_as4, SI_EIT_as5, SI_EIT_as6, SI_EIT_as7,
- SI_EIT_as8, SI_EIT_as9, SI_EIT_asa, SI_EIT_asb, SI_EIT_asc, SI_EIT_asd, SI_EIT_ase, SI_EIT_asf,
- SI_EIT_os0, SI_EIT_os1, SI_EIT_os2, SI_EIT_os3, SI_EIT_os4, SI_EIT_os5, SI_EIT_os6, SI_EIT_os7,
- SI_EIT_os8, SI_EIT_os9, SI_EIT_osa, SI_EIT_osb, SI_EIT_osc, SI_EIT_osd, SI_EIT_ose, SI_EIT_osf
+ SI_undef = -1,
+ SI_PAT = 0x00,
+ SI_CAT = 0x01,
+ SI_PMT = 0x02,
+ SI_DSMCC_a = 0x3a,
+ SI_DSMCC_b = 0x3b,
+ SI_DSMCC_c = 0x3c,
+ SI_DSMCC_d = 0x3d,
+ SI_DSMCC_e = 0x3e,
+ SI_DSMCC_f = 0x3f,
+ SI_NIT = 0x40,
+ SI_SDT = 0x42,
+ SI_EIT_act = 0x4e,
+ SI_EIT_oth = 0x4f,
+ SI_EIT_as0, SI_EIT_as1, SI_EIT_as2, SI_EIT_as3, SI_EIT_as4, SI_EIT_as5, SI_EIT_as6, SI_EIT_as7,
+ SI_EIT_as8, SI_EIT_as9, SI_EIT_asa, SI_EIT_asb, SI_EIT_asc, SI_EIT_asd, SI_EIT_ase, SI_EIT_asf,
+ SI_EIT_os0, SI_EIT_os1, SI_EIT_os2, SI_EIT_os3, SI_EIT_os4, SI_EIT_os5, SI_EIT_os6, SI_EIT_os7,
+ SI_EIT_os8, SI_EIT_os9, SI_EIT_osa, SI_EIT_osb, SI_EIT_osc, SI_EIT_osd, SI_EIT_ose, SI_EIT_osf
};
enum MPEG2_DESCRIPTOR {
- // http://www.coolstf.com/tsreader/descriptors.html
- DT_VIDEO_STREAM = 0x02,
- DT_AUDIO_STREAM = 0x03,
- DT_HIERARCHY = 0x04,
- DT_REGISTRATION = 0x05,
- DT_DATA_STREAM_ALIGNMENT = 0x06,
- DT_TARGET_BACKGROUND_GRID = 0x07,
- DT_VIDEO_WINDOW = 0x08,
- DT_CONDITIONAL_ACCESS = 0x09,
- DT_ISO_639_LANGUAGE = 0x0a,
- DT_SYSTEM_CLOCK = 0x0b,
- DT_MULTIPLEX_BUFFER_UTIL = 0x0c,
- DT_COPYRIGHT_DESCRIPTOR = 0x0d,
- DT_MAXIMUM_BITRATE = 0x0e,
- DT_PRIVATE_DATA_INDICATOR = 0x0f,
- DT_SMOOTHING_BUFFER = 0x10,
- DT_STD = 0x11, // System Target Decoder ?
- DT_IBP = 0x12,
- DT_NETWORK_NAME = 0x40,
- DT_SERVICE_LIST = 0x41,
- DT_VBI_DATA = 0x45,
- DT_SERVICE = 0x48,
- DT_LINKAGE = 0x4a,
- DT_SHORT_EVENT = 0x4d,
- DT_EXTENDED_EVENT = 0x4e,
- DT_COMPONENT = 0x50,
- DT_STREAM_IDENTIFIER = 0x52,
- DT_CONTENT = 0x54,
- DT_PARENTAL_RATING = 0x55,
- DT_TELETEXT = 0x56,
- DT_SUBTITLING = 0x59,
- DT_TERRESTRIAL_DELIV_SYS = 0x5a,
- DT_PRIVATE_DATA = 0x5f,
- //
- DT_DATA_BROADCAST_ID = 0x66,
- DT_AC3_AUDIO = 0x6a, // DVB
- DT_EXTENDED_AC3_AUDIO = 0x7a,
- //
- DT_AC3_AUDIO__2 = 0x81, // DCII ou ATSC
- DT_LOGICAL_CHANNEL = 0x83,
- DT_HD_SIMCAST_LOG_CHANNEL = 0x88
+ // http://www.coolstf.com/tsreader/descriptors.html
+ DT_VIDEO_STREAM = 0x02,
+ DT_AUDIO_STREAM = 0x03,
+ DT_HIERARCHY = 0x04,
+ DT_REGISTRATION = 0x05,
+ DT_DATA_STREAM_ALIGNMENT = 0x06,
+ DT_TARGET_BACKGROUND_GRID = 0x07,
+ DT_VIDEO_WINDOW = 0x08,
+ DT_CONDITIONAL_ACCESS = 0x09,
+ DT_ISO_639_LANGUAGE = 0x0a,
+ DT_SYSTEM_CLOCK = 0x0b,
+ DT_MULTIPLEX_BUFFER_UTIL = 0x0c,
+ DT_COPYRIGHT_DESCRIPTOR = 0x0d,
+ DT_MAXIMUM_BITRATE = 0x0e,
+ DT_PRIVATE_DATA_INDICATOR = 0x0f,
+ DT_SMOOTHING_BUFFER = 0x10,
+ DT_STD = 0x11, // System Target Decoder ?
+ DT_IBP = 0x12,
+ DT_NETWORK_NAME = 0x40,
+ DT_SERVICE_LIST = 0x41,
+ DT_VBI_DATA = 0x45,
+ DT_SERVICE = 0x48,
+ DT_LINKAGE = 0x4a,
+ DT_SHORT_EVENT = 0x4d,
+ DT_EXTENDED_EVENT = 0x4e,
+ DT_COMPONENT = 0x50,
+ DT_STREAM_IDENTIFIER = 0x52,
+ DT_CONTENT = 0x54,
+ DT_PARENTAL_RATING = 0x55,
+ DT_TELETEXT = 0x56,
+ DT_SUBTITLING = 0x59,
+ DT_TERRESTRIAL_DELIV_SYS = 0x5a,
+ DT_PRIVATE_DATA = 0x5f,
+ //
+ DT_DATA_BROADCAST_ID = 0x66,
+ DT_AC3_AUDIO = 0x6a, // DVB
+ DT_EXTENDED_AC3_AUDIO = 0x7a,
+ //
+ DT_AC3_AUDIO__2 = 0x81, // DCII ou ATSC
+ DT_LOGICAL_CHANNEL = 0x83,
+ DT_HD_SIMCAST_LOG_CHANNEL = 0x88
};
enum MPEG_TYPES {
- mpeg_us,
- mpeg_ps,
- mpeg_ts,
- mpeg_es,
- mpeg_pva
+ mpeg_us,
+ mpeg_ps,
+ mpeg_ts,
+ mpeg_es,
+ mpeg_pva
};
-extern const wchar_t *StreamTypeToName(PES_STREAM_TYPE _Type);
+extern const wchar_t* StreamTypeToName(PES_STREAM_TYPE _Type);
diff --git a/src/DSUtil/NullRenderers.cpp b/src/DSUtil/NullRenderers.cpp
index 9419ccd94..f005d2eb9 100644
--- a/src/DSUtil/NullRenderers.cpp
+++ b/src/DSUtil/NullRenderers.cpp
@@ -31,246 +31,246 @@
#include <d3d9.h>
#include <dxva.h>
-#include <dxva2api.h> // DXVA2
+#include <dxva2api.h> // DXVA2
#include <evr.h>
-#include <mfapi.h> // API Media Foundation
+#include <mfapi.h> // API Media Foundation
#include <Mferror.h>
// dxva.dll
-typedef HRESULT (__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
-typedef HRESULT (__stdcall *PTR_DXVA2CreateVideoService)(IDirect3DDevice9* pDD, REFIID riid, void** ppService);
+typedef HRESULT(__stdcall* PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
+typedef HRESULT(__stdcall* PTR_DXVA2CreateVideoService)(IDirect3DDevice9* pDD, REFIID riid, void** ppService);
class CNullVideoRendererInputPin : public CRendererInputPin,
- public IMFGetService,
- public IDirectXVideoMemoryConfiguration,
- public IMFVideoDisplayControl
+ public IMFGetService,
+ public IDirectXVideoMemoryConfiguration,
+ public IMFVideoDisplayControl
{
public :
- CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name);
- ~CNullVideoRendererInputPin() {
- if (m_pD3DDeviceManager) {
- if (m_hDevice != INVALID_HANDLE_VALUE) {
- m_pD3DDeviceManager->CloseDeviceHandle(m_hDevice);
- m_hDevice = INVALID_HANDLE_VALUE;
- }
- m_pD3DDeviceManager = NULL;
- }
- if (m_pD3DDev) {
- m_pD3DDev = NULL;
- }
- if (m_hDXVA2Lib) {
- FreeLibrary(m_hDXVA2Lib);
- }
- }
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator) {
- // Renderer shouldn't manage allocator for DXVA
- return E_NOTIMPL;
- }
-
- STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps) {
- // 1 buffer required
- memset (pProps, 0, sizeof(ALLOCATOR_PROPERTIES));
- pProps->cbBuffer = 1;
- return S_OK;
- }
-
-
- // IMFGetService
- STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
-
- // IDirectXVideoMemoryConfiguration
- STDMETHODIMP GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType);
- STDMETHODIMP SetSurfaceType(DXVA2_SurfaceType dwType);
-
-
- // IMFVideoDisplayControl
- STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetVideoWindow(HWND hwndVideo) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
- STDMETHODIMP RepaintVideo( void) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetBorderColor(COLORREF Clr) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetBorderColor(COLORREF *pClr) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetFullscreen(BOOL fFullscreen) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetFullscreen(BOOL *pfFullscreen) {
- return E_NOTIMPL;
- };
+ CNullVideoRendererInputPin(CBaseRenderer* pRenderer, HRESULT* phr, LPCWSTR Name);
+ ~CNullVideoRendererInputPin() {
+ if (m_pD3DDeviceManager) {
+ if (m_hDevice != INVALID_HANDLE_VALUE) {
+ m_pD3DDeviceManager->CloseDeviceHandle(m_hDevice);
+ m_hDevice = INVALID_HANDLE_VALUE;
+ }
+ m_pD3DDeviceManager = NULL;
+ }
+ if (m_pD3DDev) {
+ m_pD3DDev = NULL;
+ }
+ if (m_hDXVA2Lib) {
+ FreeLibrary(m_hDXVA2Lib);
+ }
+ }
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator) {
+ // Renderer shouldn't manage allocator for DXVA
+ return E_NOTIMPL;
+ }
+
+ STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps) {
+ // 1 buffer required
+ memset(pProps, 0, sizeof(ALLOCATOR_PROPERTIES));
+ pProps->cbBuffer = 1;
+ return S_OK;
+ }
+
+
+ // IMFGetService
+ STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID* ppvObject);
+
+ // IDirectXVideoMemoryConfiguration
+ STDMETHODIMP GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType* pdwType);
+ STDMETHODIMP SetSurfaceType(DXVA2_SurfaceType dwType);
+
+
+ // IMFVideoDisplayControl
+ STDMETHODIMP GetNativeVideoSize(SIZE* pszVideo, SIZE* pszARVideo) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetIdealVideoSize(SIZE* pszMin, SIZE* pszMax) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect* pnrcSource, LPRECT prcDest) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetAspectRatioMode(DWORD* pdwAspectRatioMode) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetVideoWindow(HWND hwndVideo) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetVideoWindow(HWND* phwndVideo);
+ STDMETHODIMP RepaintVideo(void) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetBorderColor(COLORREF Clr) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetBorderColor(COLORREF* pClr) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetRenderingPrefs(DWORD* pdwRenderFlags) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetFullscreen(BOOL fFullscreen) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetFullscreen(BOOL* pfFullscreen) {
+ return E_NOTIMPL;
+ };
private :
- HMODULE m_hDXVA2Lib;
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_DXVA2CreateVideoService pfDXVA2CreateVideoService;
-
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
- CComPtr<IDirect3DDeviceManager9> m_pD3DDeviceManager;
- UINT m_nResetTocken;
- HANDLE m_hDevice;
- HWND m_hWnd;
-
- void CreateSurface();
+ HMODULE m_hDXVA2Lib;
+ PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
+ PTR_DXVA2CreateVideoService pfDXVA2CreateVideoService;
+
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DDeviceManager9> m_pD3DDeviceManager;
+ UINT m_nResetTocken;
+ HANDLE m_hDevice;
+ HWND m_hWnd;
+
+ void CreateSurface();
};
-CNullVideoRendererInputPin::CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name)
- : CRendererInputPin(pRenderer, phr, Name)
- , m_hDXVA2Lib(NULL)
- , m_pD3DDev(NULL)
- , m_pD3DDeviceManager(NULL)
- , m_hDevice(INVALID_HANDLE_VALUE)
+CNullVideoRendererInputPin::CNullVideoRendererInputPin(CBaseRenderer* pRenderer, HRESULT* phr, LPCWSTR Name)
+ : CRendererInputPin(pRenderer, phr, Name)
+ , m_hDXVA2Lib(NULL)
+ , m_pD3DDev(NULL)
+ , m_pD3DDeviceManager(NULL)
+ , m_hDevice(INVALID_HANDLE_VALUE)
{
- CreateSurface();
-
- m_hDXVA2Lib = LoadLibrary(L"dxva2.dll");
- if (m_hDXVA2Lib) {
- pfDXVA2CreateDirect3DDeviceManager9 = reinterpret_cast<PTR_DXVA2CreateDirect3DDeviceManager9>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateDirect3DDeviceManager9"));
- pfDXVA2CreateVideoService = reinterpret_cast<PTR_DXVA2CreateVideoService>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateVideoService"));
- pfDXVA2CreateDirect3DDeviceManager9(&m_nResetTocken, &m_pD3DDeviceManager);
- }
-
- // Initialize Device Manager with DX surface
- if (m_pD3DDev) {
- HRESULT hr;
- hr = m_pD3DDeviceManager->ResetDevice (m_pD3DDev, m_nResetTocken);
- hr = m_pD3DDeviceManager->OpenDeviceHandle(&m_hDevice);
- }
+ CreateSurface();
+
+ m_hDXVA2Lib = LoadLibrary(L"dxva2.dll");
+ if (m_hDXVA2Lib) {
+ pfDXVA2CreateDirect3DDeviceManager9 = reinterpret_cast<PTR_DXVA2CreateDirect3DDeviceManager9>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateDirect3DDeviceManager9"));
+ pfDXVA2CreateVideoService = reinterpret_cast<PTR_DXVA2CreateVideoService>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateVideoService"));
+ pfDXVA2CreateDirect3DDeviceManager9(&m_nResetTocken, &m_pD3DDeviceManager);
+ }
+
+ // Initialize Device Manager with DX surface
+ if (m_pD3DDev) {
+ HRESULT hr;
+ hr = m_pD3DDeviceManager->ResetDevice(m_pD3DDev, m_nResetTocken);
+ hr = m_pD3DDeviceManager->OpenDeviceHandle(&m_hDevice);
+ }
}
void CNullVideoRendererInputPin::CreateSurface()
{
- HRESULT hr;
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if (!m_pD3D) {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
-
- m_hWnd = NULL; // TODO : put true window
-
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
-
- D3DPRESENT_PARAMETERS pp;
- ZeroMemory(&pp, sizeof(pp));
-
- pp.Windowed = TRUE;
- pp.hDeviceWindow = m_hWnd;
- pp.SwapEffect = D3DSWAPEFFECT_COPY;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferCount = 1;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
-
- hr = m_pD3D->CreateDevice(
- D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
+ HRESULT hr;
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if (!m_pD3D) {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+
+ m_hWnd = NULL; // TODO : put true window
+
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
+
+ D3DPRESENT_PARAMETERS pp;
+ ZeroMemory(&pp, sizeof(pp));
+
+ pp.Windowed = TRUE;
+ pp.hDeviceWindow = m_hWnd;
+ pp.SwapEffect = D3DSWAPEFFECT_COPY;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+
+ hr = m_pD3D->CreateDevice(
+ D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
}
STDMETHODIMP CNullVideoRendererInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- (riid == __uuidof(IMFGetService)) ? GetInterface((IMFGetService*)this, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (riid == __uuidof(IMFGetService)) ? GetInterface((IMFGetService*)this, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
-STDMETHODIMP CNullVideoRendererInputPin::GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject)
+STDMETHODIMP CNullVideoRendererInputPin::GetService(REFGUID guidService, REFIID riid, LPVOID* ppvObject)
{
- if (m_pD3DDeviceManager != NULL && guidService == MR_VIDEO_ACCELERATION_SERVICE) {
- if (riid == __uuidof(IDirect3DDeviceManager9)) {
- return m_pD3DDeviceManager->QueryInterface (riid, ppvObject);
- } else if (riid == __uuidof(IDirectXVideoDecoderService) || riid == __uuidof(IDirectXVideoProcessorService) ) {
- return m_pD3DDeviceManager->GetVideoService (m_hDevice, riid, ppvObject);
- } else if (riid == __uuidof(IDirectXVideoAccelerationService)) {
- // TODO : to be tested....
- return pfDXVA2CreateVideoService(m_pD3DDev, riid, ppvObject);
- } else if (riid == __uuidof(IDirectXVideoMemoryConfiguration)) {
- GetInterface ((IDirectXVideoMemoryConfiguration*)this, ppvObject);
- return S_OK;
- }
- } else if (guidService == MR_VIDEO_RENDER_SERVICE) {
- if (riid == __uuidof(IMFVideoDisplayControl)) {
- GetInterface ((IMFVideoDisplayControl*)this, ppvObject);
- return S_OK;
- }
- }
- //else if (guidService == MR_VIDEO_MIXER_SERVICE)
- //{
- // if (riid == __uuidof(IMFVideoMixerBitmap))
- // {
- // GetInterface ((IMFVideoMixerBitmap*)this, ppvObject);
- // return S_OK;
- // }
- //}
- return E_NOINTERFACE;
+ if (m_pD3DDeviceManager != NULL && guidService == MR_VIDEO_ACCELERATION_SERVICE) {
+ if (riid == __uuidof(IDirect3DDeviceManager9)) {
+ return m_pD3DDeviceManager->QueryInterface(riid, ppvObject);
+ } else if (riid == __uuidof(IDirectXVideoDecoderService) || riid == __uuidof(IDirectXVideoProcessorService)) {
+ return m_pD3DDeviceManager->GetVideoService(m_hDevice, riid, ppvObject);
+ } else if (riid == __uuidof(IDirectXVideoAccelerationService)) {
+ // TODO : to be tested....
+ return pfDXVA2CreateVideoService(m_pD3DDev, riid, ppvObject);
+ } else if (riid == __uuidof(IDirectXVideoMemoryConfiguration)) {
+ GetInterface((IDirectXVideoMemoryConfiguration*)this, ppvObject);
+ return S_OK;
+ }
+ } else if (guidService == MR_VIDEO_RENDER_SERVICE) {
+ if (riid == __uuidof(IMFVideoDisplayControl)) {
+ GetInterface((IMFVideoDisplayControl*)this, ppvObject);
+ return S_OK;
+ }
+ }
+ //else if (guidService == MR_VIDEO_MIXER_SERVICE)
+ //{
+ // if (riid == __uuidof(IMFVideoMixerBitmap))
+ // {
+ // GetInterface ((IMFVideoMixerBitmap*)this, ppvObject);
+ // return S_OK;
+ // }
+ //}
+ return E_NOINTERFACE;
}
-STDMETHODIMP CNullVideoRendererInputPin::GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType)
+STDMETHODIMP CNullVideoRendererInputPin::GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType* pdwType)
{
- if (dwTypeIndex == 0) {
- *pdwType = DXVA2_SurfaceType_DecoderRenderTarget;
- return S_OK;
- } else {
- return MF_E_NO_MORE_TYPES;
- }
+ if (dwTypeIndex == 0) {
+ *pdwType = DXVA2_SurfaceType_DecoderRenderTarget;
+ return S_OK;
+ } else {
+ return MF_E_NO_MORE_TYPES;
+ }
}
STDMETHODIMP CNullVideoRendererInputPin::SetSurfaceType(DXVA2_SurfaceType dwType)
{
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND *phwndVideo)
+STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND* phwndVideo)
{
- CheckPointer(phwndVideo, E_POINTER);
- *phwndVideo = m_hWnd; // Important to implement this method (used by mpc)
- return S_OK;
+ CheckPointer(phwndVideo, E_POINTER);
+ *phwndVideo = m_hWnd; // Important to implement this method (used by mpc)
+ return S_OK;
}
@@ -281,7 +281,7 @@ STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND *phwndVideo)
//
CNullRenderer::CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseRenderer(clsid, pName, pUnk, phr)
+ : CBaseRenderer(clsid, pName, pUnk, phr)
{
}
@@ -290,16 +290,16 @@ CNullRenderer::CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESU
//
CNullVideoRenderer::CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Video Renderer"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Video Renderer"), pUnk, phr)
{
}
HRESULT CNullVideoRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Video
+ || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ ? S_OK
+ : E_FAIL;
}
//
@@ -307,55 +307,55 @@ HRESULT CNullVideoRenderer::CheckMediaType(const CMediaType* pmt)
//
CNullUVideoRenderer::CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Video Renderer (Uncompressed)"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Video Renderer (Uncompressed)"), pUnk, phr)
{
#ifdef USE_DXVA
- m_pInputPin = new CNullVideoRendererInputPin(this,phr,L"In");
+ m_pInputPin = new CNullVideoRendererInputPin(this, phr, L"In");
#endif
}
HRESULT CNullUVideoRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- && (pmt->subtype == MEDIASUBTYPE_YV12
- || pmt->subtype == MEDIASUBTYPE_I420
- || pmt->subtype == MEDIASUBTYPE_YUYV
- || pmt->subtype == MEDIASUBTYPE_IYUV
- || pmt->subtype == MEDIASUBTYPE_YVU9
- || pmt->subtype == MEDIASUBTYPE_Y411
- || pmt->subtype == MEDIASUBTYPE_Y41P
- || pmt->subtype == MEDIASUBTYPE_YUY2
- || pmt->subtype == MEDIASUBTYPE_YVYU
- || pmt->subtype == MEDIASUBTYPE_UYVY
- || pmt->subtype == MEDIASUBTYPE_Y211
- || pmt->subtype == MEDIASUBTYPE_RGB1
- || pmt->subtype == MEDIASUBTYPE_RGB4
- || pmt->subtype == MEDIASUBTYPE_RGB8
- || pmt->subtype == MEDIASUBTYPE_RGB565
- || pmt->subtype == MEDIASUBTYPE_RGB555
- || pmt->subtype == MEDIASUBTYPE_RGB24
- || pmt->subtype == MEDIASUBTYPE_RGB32
- || pmt->subtype == MEDIASUBTYPE_ARGB1555
- || pmt->subtype == MEDIASUBTYPE_ARGB4444
- || pmt->subtype == MEDIASUBTYPE_ARGB32
- || pmt->subtype == MEDIASUBTYPE_A2R10G10B10
- || pmt->subtype == MEDIASUBTYPE_A2B10G10R10)
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Video
+ && (pmt->subtype == MEDIASUBTYPE_YV12
+ || pmt->subtype == MEDIASUBTYPE_I420
+ || pmt->subtype == MEDIASUBTYPE_YUYV
+ || pmt->subtype == MEDIASUBTYPE_IYUV
+ || pmt->subtype == MEDIASUBTYPE_YVU9
+ || pmt->subtype == MEDIASUBTYPE_Y411
+ || pmt->subtype == MEDIASUBTYPE_Y41P
+ || pmt->subtype == MEDIASUBTYPE_YUY2
+ || pmt->subtype == MEDIASUBTYPE_YVYU
+ || pmt->subtype == MEDIASUBTYPE_UYVY
+ || pmt->subtype == MEDIASUBTYPE_Y211
+ || pmt->subtype == MEDIASUBTYPE_RGB1
+ || pmt->subtype == MEDIASUBTYPE_RGB4
+ || pmt->subtype == MEDIASUBTYPE_RGB8
+ || pmt->subtype == MEDIASUBTYPE_RGB565
+ || pmt->subtype == MEDIASUBTYPE_RGB555
+ || pmt->subtype == MEDIASUBTYPE_RGB24
+ || pmt->subtype == MEDIASUBTYPE_RGB32
+ || pmt->subtype == MEDIASUBTYPE_ARGB1555
+ || pmt->subtype == MEDIASUBTYPE_ARGB4444
+ || pmt->subtype == MEDIASUBTYPE_ARGB32
+ || pmt->subtype == MEDIASUBTYPE_A2R10G10B10
+ || pmt->subtype == MEDIASUBTYPE_A2B10G10R10)
+ ? S_OK
+ : E_FAIL;
}
HRESULT CNullUVideoRenderer::DoRenderSample(IMediaSample* pSample)
{
#ifdef USE_DXVA
- CComQIPtr<IMFGetService> pService = pSample;
- if (pService != NULL) {
- CComPtr<IDirect3DSurface9> pSurface;
- pService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&pSurface);
- // TODO : render surface...
- }
+ CComQIPtr<IMFGetService> pService = pSample;
+ if (pService != NULL) {
+ CComPtr<IDirect3DSurface9> pSurface;
+ pService->GetService(MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&pSurface);
+ // TODO : render surface...
+ }
#endif
- return S_OK;
+ return S_OK;
}
//
@@ -363,23 +363,23 @@ HRESULT CNullUVideoRenderer::DoRenderSample(IMediaSample* pSample)
//
CNullAudioRenderer::CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer"), pUnk, phr)
{
}
HRESULT CNullAudioRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_Midi
- || pmt->subtype == MEDIASUBTYPE_MPEG2_AUDIO
- || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
- || pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
- || pmt->subtype == MEDIASUBTYPE_DTS
- || pmt->subtype == MEDIASUBTYPE_SDDS
- || pmt->subtype == MEDIASUBTYPE_MPEG1AudioPayload
- || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Audio
+ || pmt->majortype == MEDIATYPE_Midi
+ || pmt->subtype == MEDIASUBTYPE_MPEG2_AUDIO
+ || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
+ || pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
+ || pmt->subtype == MEDIASUBTYPE_DTS
+ || pmt->subtype == MEDIASUBTYPE_SDDS
+ || pmt->subtype == MEDIASUBTYPE_MPEG1AudioPayload
+ || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
+ ? S_OK
+ : E_FAIL;
}
//
@@ -387,21 +387,21 @@ HRESULT CNullAudioRenderer::CheckMediaType(const CMediaType* pmt)
//
CNullUAudioRenderer::CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer (Uncompressed)"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer (Uncompressed)"), pUnk, phr)
{
}
HRESULT CNullUAudioRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && (pmt->subtype == MEDIASUBTYPE_PCM
- || pmt->subtype == MEDIASUBTYPE_IEEE_FLOAT
- || pmt->subtype == MEDIASUBTYPE_DRM_Audio
- || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
- || pmt->subtype == MEDIASUBTYPE_RAW_SPORT
- || pmt->subtype == MEDIASUBTYPE_SPDIF_TAG_241h)
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Audio
+ && (pmt->subtype == MEDIASUBTYPE_PCM
+ || pmt->subtype == MEDIASUBTYPE_IEEE_FLOAT
+ || pmt->subtype == MEDIASUBTYPE_DRM_Audio
+ || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
+ || pmt->subtype == MEDIASUBTYPE_RAW_SPORT
+ || pmt->subtype == MEDIASUBTYPE_SPDIF_TAG_241h)
+ ? S_OK
+ : E_FAIL;
}
//
@@ -410,18 +410,18 @@ HRESULT CNullUAudioRenderer::CheckMediaType(const CMediaType* pmt)
HRESULT CNullTextRenderer::CTextInputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Text
- || pmt->majortype == MEDIATYPE_ScriptCommand
- || pmt->majortype == MEDIATYPE_Subtitle
- || pmt->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || pmt->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || pmt->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Text
+ || pmt->majortype == MEDIATYPE_ScriptCommand
+ || pmt->majortype == MEDIATYPE_Subtitle
+ || pmt->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || pmt->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || pmt->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE
+ ? S_OK
+ : E_FAIL;
}
CNullTextRenderer::CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseFilter(NAME("CNullTextRenderer"), pUnk, this, __uuidof(this), phr)
+ : CBaseFilter(NAME("CNullTextRenderer"), pUnk, this, __uuidof(this), phr)
{
- m_pInput.Attach(DNew CTextInputPin(this, this, phr));
+ m_pInput.Attach(DNew CTextInputPin(this, this, phr));
}
diff --git a/src/DSUtil/NullRenderers.h b/src/DSUtil/NullRenderers.h
index c7d083354..f56c14112 100644
--- a/src/DSUtil/NullRenderers.h
+++ b/src/DSUtil/NullRenderers.h
@@ -29,68 +29,68 @@
class CNullRenderer : public CBaseRenderer
{
protected:
- virtual HRESULT DoRenderSample(IMediaSample* pSample) { return S_OK; }
+ virtual HRESULT DoRenderSample(IMediaSample* pSample) { return S_OK; }
public:
- CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr);
+ CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("579883A0-4E2D-481F-9436-467AAFAB7DE8"))
- CNullVideoRenderer : public CNullRenderer
+ CNullVideoRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("DD9ED57D-6ABF-42E8-89A2-11D04798DC58"))
- CNullUVideoRenderer : public CNullRenderer
+ CNullUVideoRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
- virtual HRESULT DoRenderSample(IMediaSample* pSample);
+ CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual HRESULT DoRenderSample(IMediaSample* pSample);
};
class __declspec(uuid("0C38BDFD-8C17-4E00-A344-F89397D3E22A"))
- CNullAudioRenderer : public CNullRenderer
+ CNullAudioRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("64A45125-7343-4772-9DA4-179FAC9D462C"))
- CNullUAudioRenderer : public CNullRenderer
+ CNullUAudioRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("655D7613-C26C-4A25-BBBD-3C9C516122CC"))
- CNullTextRenderer : public CBaseFilter, public CCritSec
+ CNullTextRenderer : public CBaseFilter, public CCritSec
{
- class CTextInputPin : public CBaseInputPin
- {
- public:
- CTextInputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseInputPin(NAME("CTextInputPin"), pFilter, pLock, phr, L"In") {}
- HRESULT CheckMediaType(const CMediaType* pmt);
- };
+ class CTextInputPin : public CBaseInputPin
+ {
+ public:
+ CTextInputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
+ : CBaseInputPin(NAME("CTextInputPin"), pFilter, pLock, phr, L"In") {}
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ };
- CAutoPtr<CTextInputPin> m_pInput;
+ CAutoPtr<CTextInputPin> m_pInput;
public:
- CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr);
- int GetPinCount() { return (int)!!m_pInput; }
- CBasePin* GetPin(int n) { return n == 0 ? (CBasePin*)m_pInput : NULL; }
+ CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ int GetPinCount() { return (int)!!m_pInput; }
+ CBasePin* GetPin(int n) { return n == 0 ? (CBasePin*)m_pInput : NULL; }
};
diff --git a/src/DSUtil/SysVersion.cpp b/src/DSUtil/SysVersion.cpp
index 82c18ef40..f6f30f9b9 100644
--- a/src/DSUtil/SysVersion.cpp
+++ b/src/DSUtil/SysVersion.cpp
@@ -29,9 +29,9 @@ const DWORD SysVersion::version = MAKEWORD(fullVersion.dwMinorVersion, fullVersi
OSVERSIONINFOEX SysVersion::InitFullVersion()
{
- OSVERSIONINFOEX fullVersion = {0};
- fullVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- GetVersionEx((LPOSVERSIONINFO)&fullVersion);
+ OSVERSIONINFOEX fullVersion = {0};
+ fullVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ GetVersionEx((LPOSVERSIONINFO)&fullVersion);
- return fullVersion;
+ return fullVersion;
}
diff --git a/src/DSUtil/SysVersion.h b/src/DSUtil/SysVersion.h
index 231db4e6d..a7d3e7235 100644
--- a/src/DSUtil/SysVersion.h
+++ b/src/DSUtil/SysVersion.h
@@ -26,21 +26,21 @@
class SysVersion
{
- SysVersion() {};
+ SysVersion() {};
- static OSVERSIONINFOEX InitFullVersion();
+ static OSVERSIONINFOEX InitFullVersion();
- static const OSVERSIONINFOEX fullVersion;
- static const DWORD version;
+ static const OSVERSIONINFOEX fullVersion;
+ static const DWORD version;
public:
- static OSVERSIONINFOEX GetFullVersion() { return fullVersion; }
- static DWORD GetVersion() { return version; }
+ static OSVERSIONINFOEX GetFullVersion() { return fullVersion; }
+ static DWORD GetVersion() { return version; }
- static bool IsXPOrLater() { return (version >= 0x0501); }
- static bool IsVista() { return (version == 0x0600); }
- static bool IsVistaOrLater() { return (version >= 0x0600); }
- static bool Is7() { return (version == 0x0601); }
- static bool Is7OrLater() { return (version >= 0x0601); }
- //static bool Is8() { return (version == 0x0602); }
+ static bool IsXPOrLater() { return (version >= 0x0501); }
+ static bool IsVista() { return (version == 0x0600); }
+ static bool IsVistaOrLater() { return (version >= 0x0600); }
+ static bool Is7() { return (version == 0x0601); }
+ static bool Is7OrLater() { return (version >= 0x0601); }
+ //static bool Is8() { return (version == 0x0602); }
};
diff --git a/src/DSUtil/WinAPIUtils.cpp b/src/DSUtil/WinAPIUtils.cpp
index 4c6080823..61cde7bb6 100644
--- a/src/DSUtil/WinAPIUtils.cpp
+++ b/src/DSUtil/WinAPIUtils.cpp
@@ -28,234 +28,234 @@
bool SetPrivilege(LPCTSTR privilege, bool bEnable)
{
- HANDLE hToken;
- TOKEN_PRIVILEGES tkp;
+ HANDLE hToken;
+ TOKEN_PRIVILEGES tkp;
- SetThreadExecutionState (ES_CONTINUOUS);
+ SetThreadExecutionState(ES_CONTINUOUS);
- // Get a token for this process.
- if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
- return false;
- }
+ // Get a token for this process.
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
+ return false;
+ }
- // Get the LUID for the privilege.
- LookupPrivilegeValue(NULL, privilege, &tkp.Privileges[0].Luid);
+ // Get the LUID for the privilege.
+ LookupPrivilegeValue(NULL, privilege, &tkp.Privileges[0].Luid);
- tkp.PrivilegeCount = 1; // one privilege to set
- tkp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
+ tkp.PrivilegeCount = 1; // one privilege to set
+ tkp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
- // Set the privilege for this process.
- AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
+ // Set the privilege for this process.
+ AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
- return (GetLastError() == ERROR_SUCCESS);
+ return (GetLastError() == ERROR_SUCCESS);
}
CString GetHiveName(HKEY hive)
{
- switch ((ULONG_PTR)hive) {
- case (ULONG_PTR)HKEY_CLASSES_ROOT:
- return _T("HKEY_CLASSES_ROOT");
- case (ULONG_PTR)HKEY_CURRENT_USER:
- return _T("HKEY_CURRENT_USER");
- case (ULONG_PTR)HKEY_LOCAL_MACHINE:
- return _T("HKEY_LOCAL_MACHINE");
- case (ULONG_PTR)HKEY_USERS:
- return _T("HKEY_USERS");
- case (ULONG_PTR)HKEY_PERFORMANCE_DATA:
- return _T("HKEY_PERFORMANCE_DATA");
- case (ULONG_PTR)HKEY_CURRENT_CONFIG:
- return _T("HKEY_CURRENT_CONFIG");
- case (ULONG_PTR)HKEY_DYN_DATA:
- return _T("HKEY_DYN_DATA");
- case (ULONG_PTR)HKEY_PERFORMANCE_TEXT:
- return _T("HKEY_PERFORMANCE_TEXT");
- case (ULONG_PTR)HKEY_PERFORMANCE_NLSTEXT:
- return _T("HKEY_PERFORMANCE_NLSTEXT");
- default:
- return _T("");
- }
+ switch ((ULONG_PTR)hive) {
+ case (ULONG_PTR)HKEY_CLASSES_ROOT:
+ return _T("HKEY_CLASSES_ROOT");
+ case (ULONG_PTR)HKEY_CURRENT_USER:
+ return _T("HKEY_CURRENT_USER");
+ case (ULONG_PTR)HKEY_LOCAL_MACHINE:
+ return _T("HKEY_LOCAL_MACHINE");
+ case (ULONG_PTR)HKEY_USERS:
+ return _T("HKEY_USERS");
+ case (ULONG_PTR)HKEY_PERFORMANCE_DATA:
+ return _T("HKEY_PERFORMANCE_DATA");
+ case (ULONG_PTR)HKEY_CURRENT_CONFIG:
+ return _T("HKEY_CURRENT_CONFIG");
+ case (ULONG_PTR)HKEY_DYN_DATA:
+ return _T("HKEY_DYN_DATA");
+ case (ULONG_PTR)HKEY_PERFORMANCE_TEXT:
+ return _T("HKEY_PERFORMANCE_TEXT");
+ case (ULONG_PTR)HKEY_PERFORMANCE_NLSTEXT:
+ return _T("HKEY_PERFORMANCE_NLSTEXT");
+ default:
+ return _T("");
+ }
}
bool ExportRegistryKey(CStdioFile& file, HKEY hKeyRoot, CString keyName)
{
- HKEY hKey = NULL;
- if (RegOpenKeyEx(hKeyRoot, keyName, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
- return false;
- }
-
- DWORD subKeysCount = 0, maxSubKeyLen = 0;
- DWORD valuesCount = 0, maxValueNameLen = 0, maxValueDataLen = 0;
- if (RegQueryInfoKey(hKey, NULL, NULL, NULL, &subKeysCount, &maxSubKeyLen, NULL, &valuesCount, &maxValueNameLen, &maxValueDataLen, NULL, NULL) != ERROR_SUCCESS) {
- return false;
- }
- maxSubKeyLen += 1;
- maxValueNameLen += 1;
-
- CString buffer;
-
- buffer.Format(_T("[%s\\%s]\n"), GetHiveName(hKeyRoot), keyName);
- file.WriteString(buffer);
-
- CString valueName;
- DWORD valueNameLen, valueDataLen, type;
- BYTE* data = DNew BYTE[maxValueDataLen];
-
- for (DWORD indexValue=0; indexValue < valuesCount; indexValue++) {
- valueNameLen = maxValueNameLen;
- valueDataLen = maxValueDataLen;
-
- if (RegEnumValue(hKey, indexValue, valueName.GetBuffer(maxValueNameLen), &valueNameLen, NULL, &type, data, &valueDataLen) != ERROR_SUCCESS) {
- return false;
- }
-
- switch (type) {
- case REG_SZ:
- {
- CString str((TCHAR*)data);
- str.Replace(_T("\\"), _T("\\\\"));
- str.Replace(_T("\""), _T("\\\""));
- buffer.Format(_T("\"%s\"=\"%s\"\n"), valueName, str);
- file.WriteString(buffer);
- }
- break;
- case REG_BINARY:
- buffer.Format(_T("\"%s\"=hex:%02x"), valueName, data[0]);
- file.WriteString(buffer);
- for (DWORD i=1; i < valueDataLen; i++) {
- buffer.Format(_T(",%02x"), data[i]);
- file.WriteString(buffer);
- }
- file.WriteString(_T("\n"));
- break;
- case REG_DWORD:
- buffer.Format(_T("\"%s\"=dword:%08x\n"), valueName, *((DWORD*)data));
- file.WriteString(buffer);
- break;
- default:
- {
- CString msg;
- msg.Format(_T("The value \"%s\\%s\\%s\" has an unsupported type and has been ignored.\nPlease report this error to the developers."),
- GetHiveName(hKeyRoot), keyName, valueName);
- AfxMessageBox(msg, MB_ICONERROR | MB_OK);
- }
- delete[] data;
- return false;
- }
- }
-
- delete[] data;
-
- file.WriteString(_T("\n"));
-
- CString subKeyName;
- DWORD subKeyLen;
-
- for (DWORD indexSubKey=0; indexSubKey < subKeysCount; indexSubKey++) {
- subKeyLen = maxSubKeyLen;
-
- if (RegEnumKeyEx(hKey, indexSubKey, subKeyName.GetBuffer(maxSubKeyLen), &subKeyLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
- return false;
- }
-
- buffer.Format(_T("%s\\%s"), keyName, subKeyName);
-
- if (!ExportRegistryKey(file, hKeyRoot, buffer)) {
- return false;
- }
- }
-
- RegCloseKey(hKey);
-
- return true;
+ HKEY hKey = NULL;
+ if (RegOpenKeyEx(hKeyRoot, keyName, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
+ return false;
+ }
+
+ DWORD subKeysCount = 0, maxSubKeyLen = 0;
+ DWORD valuesCount = 0, maxValueNameLen = 0, maxValueDataLen = 0;
+ if (RegQueryInfoKey(hKey, NULL, NULL, NULL, &subKeysCount, &maxSubKeyLen, NULL, &valuesCount, &maxValueNameLen, &maxValueDataLen, NULL, NULL) != ERROR_SUCCESS) {
+ return false;
+ }
+ maxSubKeyLen += 1;
+ maxValueNameLen += 1;
+
+ CString buffer;
+
+ buffer.Format(_T("[%s\\%s]\n"), GetHiveName(hKeyRoot), keyName);
+ file.WriteString(buffer);
+
+ CString valueName;
+ DWORD valueNameLen, valueDataLen, type;
+ BYTE* data = DNew BYTE[maxValueDataLen];
+
+ for (DWORD indexValue = 0; indexValue < valuesCount; indexValue++) {
+ valueNameLen = maxValueNameLen;
+ valueDataLen = maxValueDataLen;
+
+ if (RegEnumValue(hKey, indexValue, valueName.GetBuffer(maxValueNameLen), &valueNameLen, NULL, &type, data, &valueDataLen) != ERROR_SUCCESS) {
+ return false;
+ }
+
+ switch (type) {
+ case REG_SZ: {
+ CString str((TCHAR*)data);
+ str.Replace(_T("\\"), _T("\\\\"));
+ str.Replace(_T("\""), _T("\\\""));
+ buffer.Format(_T("\"%s\"=\"%s\"\n"), valueName, str);
+ file.WriteString(buffer);
+ }
+ break;
+ case REG_BINARY:
+ buffer.Format(_T("\"%s\"=hex:%02x"), valueName, data[0]);
+ file.WriteString(buffer);
+ for (DWORD i = 1; i < valueDataLen; i++) {
+ buffer.Format(_T(",%02x"), data[i]);
+ file.WriteString(buffer);
+ }
+ file.WriteString(_T("\n"));
+ break;
+ case REG_DWORD:
+ buffer.Format(_T("\"%s\"=dword:%08x\n"), valueName, *((DWORD*)data));
+ file.WriteString(buffer);
+ break;
+ default: {
+ CString msg;
+ msg.Format(_T("The value \"%s\\%s\\%s\" has an unsupported type and has been ignored.\nPlease report this error to the developers."),
+ GetHiveName(hKeyRoot), keyName, valueName);
+ AfxMessageBox(msg, MB_ICONERROR | MB_OK);
+ }
+ delete[] data;
+ return false;
+ }
+ }
+
+ delete[] data;
+
+ file.WriteString(_T("\n"));
+
+ CString subKeyName;
+ DWORD subKeyLen;
+
+ for (DWORD indexSubKey = 0; indexSubKey < subKeysCount; indexSubKey++) {
+ subKeyLen = maxSubKeyLen;
+
+ if (RegEnumKeyEx(hKey, indexSubKey, subKeyName.GetBuffer(maxSubKeyLen), &subKeyLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
+ return false;
+ }
+
+ buffer.Format(_T("%s\\%s"), keyName, subKeyName);
+
+ if (!ExportRegistryKey(file, hKeyRoot, buffer)) {
+ return false;
+ }
+ }
+
+ RegCloseKey(hKey);
+
+ return true;
}
UINT GetAdapter(IDirect3D9* pD3D, HWND hWnd)
{
- if (hWnd == NULL || pD3D == NULL) {
- return D3DADAPTER_DEFAULT;
- }
-
- HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
- if (hMonitor == NULL) {
- return D3DADAPTER_DEFAULT;
- }
-
- for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
- HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if (hAdpMon == hMonitor) {
- return adp;
- }
- }
-
- return D3DADAPTER_DEFAULT;
+ if (hWnd == NULL || pD3D == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
+
+ HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
+ if (hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
+
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
+ if (hAdpMon == hMonitor) {
+ return adp;
+ }
+ }
+
+ return D3DADAPTER_DEFAULT;
}
int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX* /*lpelfe*/, NEWTEXTMETRICEX* /*lpntme*/, int /*FontType*/, LPARAM lParam)
{
- LPARAM* l = (LPARAM*)lParam;
- *l = TRUE;
- return TRUE;
+ LPARAM* l = (LPARAM*)lParam;
+ *l = TRUE;
+ return TRUE;
}
void GetMessageFont(LOGFONT* lf)
{
- SecureZeroMemory(lf, sizeof(LOGFONT));
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- if (!SysVersion::IsVistaOrLater())
- ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
-
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- *lf = ncm.lfMessageFont;
+ SecureZeroMemory(lf, sizeof(LOGFONT));
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ if (!SysVersion::IsVistaOrLater()) {
+ ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
+ }
+
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
+ *lf = ncm.lfMessageFont;
}
void GetStatusFont(LOGFONT* lf)
{
- SecureZeroMemory(lf, sizeof(LOGFONT));
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- if (!SysVersion::IsVistaOrLater())
- ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
-
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- *lf = ncm.lfStatusFont;
+ SecureZeroMemory(lf, sizeof(LOGFONT));
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ if (!SysVersion::IsVistaOrLater()) {
+ ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
+ }
+
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
+ *lf = ncm.lfStatusFont;
}
bool IsFontInstalled(LPCTSTR lpszFont)
{
- // Get the screen DC
- CDC dc;
- if (!dc.CreateCompatibleDC(NULL)) {
- return false;
- }
-
- LOGFONT lf = {0};
- // Any character set will do
- lf.lfCharSet = DEFAULT_CHARSET;
- // Set the facename to check for
- _tcscpy_s(lf.lfFaceName, lpszFont);
- LPARAM lParam = 0;
- // Enumerate fonts
- EnumFontFamiliesEx(dc.GetSafeHdc(), &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)&lParam, 0);
-
- return lParam ? true : false;
+ // Get the screen DC
+ CDC dc;
+ if (!dc.CreateCompatibleDC(NULL)) {
+ return false;
+ }
+
+ LOGFONT lf = {0};
+ // Any character set will do
+ lf.lfCharSet = DEFAULT_CHARSET;
+ // Set the facename to check for
+ _tcscpy_s(lf.lfFaceName, lpszFont);
+ LPARAM lParam = 0;
+ // Enumerate fonts
+ EnumFontFamiliesEx(dc.GetSafeHdc(), &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)&lParam, 0);
+
+ return lParam ? true : false;
}
bool ExploreToFile(CString path)
{
- bool success = false;
- HRESULT res = CoInitialize(NULL);
+ bool success = false;
+ HRESULT res = CoInitialize(NULL);
- if (res == S_OK || res == S_FALSE) {
- PIDLIST_ABSOLUTE pidl;
+ if (res == S_OK || res == S_FALSE) {
+ PIDLIST_ABSOLUTE pidl;
- if (SHParseDisplayName(path, NULL, &pidl, 0, NULL) == S_OK) {
- success = SUCCEEDED(SHOpenFolderAndSelectItems(pidl, 0, NULL, 0));
- CoTaskMemFree(pidl);
- }
+ if (SHParseDisplayName(path, NULL, &pidl, 0, NULL) == S_OK) {
+ success = SUCCEEDED(SHOpenFolderAndSelectItems(pidl, 0, NULL, 0));
+ CoTaskMemFree(pidl);
+ }
- CoUninitialize();
- }
+ CoUninitialize();
+ }
- return success;
+ return success;
}
diff --git a/src/DSUtil/WinAPIUtils.h b/src/DSUtil/WinAPIUtils.h
index 33231f878..918480ff6 100644
--- a/src/DSUtil/WinAPIUtils.h
+++ b/src/DSUtil/WinAPIUtils.h
@@ -27,9 +27,9 @@
struct IDirect3D9;
-bool SetPrivilege(LPCTSTR privilege, bool bEnable=true);
+bool SetPrivilege(LPCTSTR privilege, bool bEnable = true);
-bool ExportRegistryKey(CStdioFile& file, HKEY hKeyRoot, CString keyName=_T(""));
+bool ExportRegistryKey(CStdioFile& file, HKEY hKeyRoot, CString keyName = _T(""));
UINT GetAdapter(IDirect3D9* pD3D, HWND hWnd);
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp
index 99ce76aa5..3df2726cb 100644
--- a/src/DSUtil/text.cpp
+++ b/src/DSUtil/text.cpp
@@ -26,164 +26,164 @@
DWORD CharSetToCodePage(DWORD dwCharSet)
{
- if (dwCharSet == CP_UTF8) {
- return CP_UTF8;
- }
- if (dwCharSet == CP_UTF7) {
- return CP_UTF7;
- }
- CHARSETINFO cs= {0};
- ::TranslateCharsetInfo((DWORD *)dwCharSet, &cs, TCI_SRCCHARSET);
- return cs.ciACP;
+ if (dwCharSet == CP_UTF8) {
+ return CP_UTF8;
+ }
+ if (dwCharSet == CP_UTF7) {
+ return CP_UTF7;
+ }
+ CHARSETINFO cs = {0};
+ ::TranslateCharsetInfo((DWORD*)dwCharSet, &cs, TCI_SRCCHARSET);
+ return cs.ciACP;
}
CStringA ConvertMBCS(CStringA str, DWORD SrcCharSet, DWORD DstCharSet)
{
- WCHAR* utf16 = DNew WCHAR[str.GetLength()+1];
- memset(utf16, 0, (str.GetLength()+1)*sizeof(WCHAR));
+ WCHAR* utf16 = DNew WCHAR[str.GetLength() + 1];
+ memset(utf16, 0, (str.GetLength() + 1)*sizeof(WCHAR));
- CHAR* mbcs = DNew CHAR[str.GetLength()*6+1];
- memset(mbcs, 0, str.GetLength()*6+1);
+ CHAR* mbcs = DNew CHAR[str.GetLength() * 6 + 1];
+ memset(mbcs, 0, str.GetLength() * 6 + 1);
- int len = MultiByteToWideChar(
- CharSetToCodePage(SrcCharSet), 0,
- str, -1, // null terminated string
- utf16, str.GetLength()+1);
+ int len = MultiByteToWideChar(
+ CharSetToCodePage(SrcCharSet), 0,
+ str, -1, // null terminated string
+ utf16, str.GetLength() + 1);
- len = WideCharToMultiByte(
- CharSetToCodePage(DstCharSet), 0,
- utf16, len,
- mbcs, str.GetLength()*6,
- NULL, NULL);
+ len = WideCharToMultiByte(
+ CharSetToCodePage(DstCharSet), 0,
+ utf16, len,
+ mbcs, str.GetLength() * 6,
+ NULL, NULL);
- str = mbcs;
+ str = mbcs;
- delete [] utf16;
- delete [] mbcs;
+ delete [] utf16;
+ delete [] mbcs;
- return str;
+ return str;
}
CStringA UrlEncode(CStringA str, bool fRaw)
{
- CStringA urlstr;
-
- for (int i = 0; i < str.GetLength(); i++) {
- CHAR c = str[i];
- if (fRaw && c == '+') {
- urlstr += "%2B";
- } else if (c > 0x20 && c < 0x7f && c != '&') {
- urlstr += c;
- } else if (c == 0x20) {
- urlstr += fRaw ? ' ' : '+';
- } else {
- CStringA tmp;
- tmp.Format("%%%02x", (BYTE)c);
- urlstr += tmp;
- }
- }
-
- return urlstr;
+ CStringA urlstr;
+
+ for (int i = 0; i < str.GetLength(); i++) {
+ CHAR c = str[i];
+ if (fRaw && c == '+') {
+ urlstr += "%2B";
+ } else if (c > 0x20 && c < 0x7f && c != '&') {
+ urlstr += c;
+ } else if (c == 0x20) {
+ urlstr += fRaw ? ' ' : '+';
+ } else {
+ CStringA tmp;
+ tmp.Format("%%%02x", (BYTE)c);
+ urlstr += tmp;
+ }
+ }
+
+ return urlstr;
}
CStringA UrlDecode(CStringA str, bool fRaw)
{
- str.Replace("&amp;", "&");
-
- CHAR* s = str.GetBuffer(str.GetLength());
- CHAR* e = s + str.GetLength();
- CHAR* s1 = s;
- CHAR* s2 = s;
- while (s1 < e) {
- CHAR s11 = (s1 < e-1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
- CHAR s12 = (s1 < e-2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
-
- if (*s1 == '%' && s1 < e-2
- && (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
- && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f')) {
- s1[1] = s11;
- s1[2] = s12;
- *s2 = 0;
- if (s1[1] >= '0' && s1[1] <= '9') {
- *s2 |= s1[1]-'0';
- } else if (s1[1] >= 'a' && s1[1] <= 'f') {
- *s2 |= s1[1]-'a'+10;
- }
- *s2 <<= 4;
- if (s1[2] >= '0' && s1[2] <= '9') {
- *s2 |= s1[2]-'0';
- } else if (s1[2] >= 'a' && s1[2] <= 'f') {
- *s2 |= s1[2]-'a'+10;
- }
- s1 += 2;
- } else {
- *s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
- }
-
- s1++;
- s2++;
- }
-
- str.ReleaseBuffer(int(s2 - s));
-
- return str;
+ str.Replace("&amp;", "&");
+
+ CHAR* s = str.GetBuffer(str.GetLength());
+ CHAR* e = s + str.GetLength();
+ CHAR* s1 = s;
+ CHAR* s2 = s;
+ while (s1 < e) {
+ CHAR s11 = (s1 < e - 1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
+ CHAR s12 = (s1 < e - 2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
+
+ if (*s1 == '%' && s1 < e - 2
+ && (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
+ && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f')) {
+ s1[1] = s11;
+ s1[2] = s12;
+ *s2 = 0;
+ if (s1[1] >= '0' && s1[1] <= '9') {
+ *s2 |= s1[1] - '0';
+ } else if (s1[1] >= 'a' && s1[1] <= 'f') {
+ *s2 |= s1[1] - 'a' + 10;
+ }
+ *s2 <<= 4;
+ if (s1[2] >= '0' && s1[2] <= '9') {
+ *s2 |= s1[2] - '0';
+ } else if (s1[2] >= 'a' && s1[2] <= 'f') {
+ *s2 |= s1[2] - 'a' + 10;
+ }
+ s1 += 2;
+ } else {
+ *s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
+ }
+
+ s1++;
+ s2++;
+ }
+
+ str.ReleaseBuffer(int(s2 - s));
+
+ return str;
}
CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
{
- tag.Trim();
- attribs.RemoveAll();
-
- fClosing = !tag.IsEmpty() ? tag[0] == '/' : false;
- tag.TrimLeft('/');
-
- int i = tag.Find(' ');
- if (i < 0) {
- i = tag.GetLength();
- }
- CString type = tag.Left(i).MakeLower();
- tag = tag.Mid(i).Trim();
-
- while ((i = tag.Find('=')) > 0) {
- CString attrib = tag.Left(i).Trim().MakeLower();
- tag = tag.Mid(i+1);
- for (i = 0; i < tag.GetLength() && _istspace(tag[i]); i++) {
- ;
- }
- tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
- if (!tag.IsEmpty() && tag[0] == '\"') {
- tag = tag.Mid(1);
- i = tag.Find('\"');
- } else {
- i = tag.Find(' ');
- }
- if (i < 0) {
- i = tag.GetLength();
- }
- CString param = tag.Left(i).Trim();
- if (!param.IsEmpty()) {
- attribs[attrib] = param;
- }
- tag = i+1 < tag.GetLength() ? tag.Mid(i+1) : _T("");
- }
-
- return type;
+ tag.Trim();
+ attribs.RemoveAll();
+
+ fClosing = !tag.IsEmpty() ? tag[0] == '/' : false;
+ tag.TrimLeft('/');
+
+ int i = tag.Find(' ');
+ if (i < 0) {
+ i = tag.GetLength();
+ }
+ CString type = tag.Left(i).MakeLower();
+ tag = tag.Mid(i).Trim();
+
+ while ((i = tag.Find('=')) > 0) {
+ CString attrib = tag.Left(i).Trim().MakeLower();
+ tag = tag.Mid(i + 1);
+ for (i = 0; i < tag.GetLength() && _istspace(tag[i]); i++) {
+ ;
+ }
+ tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
+ if (!tag.IsEmpty() && tag[0] == '\"') {
+ tag = tag.Mid(1);
+ i = tag.Find('\"');
+ } else {
+ i = tag.Find(' ');
+ }
+ if (i < 0) {
+ i = tag.GetLength();
+ }
+ CString param = tag.Left(i).Trim();
+ if (!param.IsEmpty()) {
+ attribs[attrib] = param;
+ }
+ tag = i + 1 < tag.GetLength() ? tag.Mid(i + 1) : _T("");
+ }
+
+ return type;
}
CAtlList<CString>& MakeLower(CAtlList<CString>& sl)
{
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- sl.GetNext(pos).MakeLower();
- }
- return sl;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ sl.GetNext(pos).MakeLower();
+ }
+ return sl;
}
CAtlList<CString>& MakeUpper(CAtlList<CString>& sl)
{
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- sl.GetNext(pos).MakeUpper();
- }
- return sl;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ sl.GetNext(pos).MakeUpper();
+ }
+ return sl;
}
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h
index 5752f8ff3..87aa16e0c 100644
--- a/src/DSUtil/text.h
+++ b/src/DSUtil/text.h
@@ -28,52 +28,52 @@
template<class T, typename SEP>
T Explode(const T& str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
- sl.RemoveAll();
+ sl.RemoveAll();
- for (int i = 0, j = 0; ; i = j+1) {
- j = str.Find(sep, i);
+ for (int i = 0, j = 0; ; i = j + 1) {
+ j = str.Find(sep, i);
- if (j < 0 || sl.GetCount() == limit-1) {
- sl.AddTail(str.Mid(i).Trim());
- break;
- } else {
- sl.AddTail(str.Mid(i, j-i).Trim());
- }
- }
+ if (j < 0 || sl.GetCount() == limit - 1) {
+ sl.AddTail(str.Mid(i).Trim());
+ break;
+ } else {
+ sl.AddTail(str.Mid(i, j - i).Trim());
+ }
+ }
- return sl.GetHead();
+ return sl.GetHead();
}
template<class T, typename SEP>
T ExplodeMin(const T& str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
- Explode(str, sl, sep, limit);
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- POSITION tmp = pos;
- if (sl.GetNext(pos).IsEmpty()) {
- sl.RemoveAt(tmp);
- }
- }
- if (sl.IsEmpty()) {
- sl.AddTail(T()); // eh
- }
+ Explode(str, sl, sep, limit);
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ POSITION tmp = pos;
+ if (sl.GetNext(pos).IsEmpty()) {
+ sl.RemoveAt(tmp);
+ }
+ }
+ if (sl.IsEmpty()) {
+ sl.AddTail(T()); // eh
+ }
- return sl.GetHead();
+ return sl.GetHead();
}
template<class T, typename SEP>
T Implode(const CAtlList<T>& sl, SEP sep)
{
- T ret;
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- ret += sl.GetNext(pos);
- if (pos) {
- ret += sep;
- }
- }
- return ret;
+ T ret;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ ret += sl.GetNext(pos);
+ if (pos) {
+ ret += sep;
+ }
+ }
+ return ret;
}
extern CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing);