posts - 36, comments - 30, trackbacks - 0, articles - 0

     摘要: 举例分析: 首先是一段例子: Test.m2v   00 00 01 B3 08 00 80 23 00 FA 20 30 00 00 01 B5   根据13813-2 Table 6-1 Start code values: 00 00 01 B3 为sequence_header_code.根据6.2.2节(附)    ...  阅读全文

posted @ 2007-05-27 17:59 vcommon 阅读(4871) | 评论 (5)编辑 收藏

FirteX的程序思想和组织结构

1:FirteX使用MFC架构。
2:FirteX结构相当灵活,可以任意扩充。
3:基本思想:
      1:主要的namespace:
               a:Collection:有多种Collection,DirCollection ,FileListCollection,TrecCollection,FirTexCollection
               b:parser:有多种parser,CPlainParser,和通过IParserPlugin扩充的CHTMLParserPlugin
               c:analyzer:有多种analyzer,CChineseAnalyzer,CDateTimeAnalyzer
      1:程序流程:
               通过一个实例解释程序流程:从一个文件夹的所有文本文件中建立索引并查找。
               a:选择参数。使用DirCollection收集一个文件夹的内容,指定CPlainParser从txt文件中建立索引,指定CChineseAnalyzer对中文词语进行索引。
               b:CIndexWriter 开始。 CIndexWriter::prepareBuildIndex中根据参数创建所有的实例,比如DirCollection,CPlainParser,CChineseAnalyzer,CIndexWriter。
               c:CCollection::scan()完成建立索引的过程。DirCollection遍历所有的文件,使CAnalyzer::analyze所有的文件。CAnalyzer将先用CPlainParser parse一遍,最后自己再analyze一遍。注意这两遍完成了最主要的工作。
               d:CPlainParser 的parser过程。
                        1:schema:title,contents,能从文件中查询多种段,CPlainParser 只有contents,html中有url,title等可以分schema查询。
                        2:CMetadata,可以是MT_STR,MT_NUMBER等可以查询词或数字。
                        3:CField类,通过CReader分析,是某种schema下的某种CMetada
                        4:Parser只是将Analyzer分开,以便多次多种Analyzer。
               e:CChineseAnalyzer把所有信息存入索引文件。CChineseAnalyzer进行的最主要的分词等功能。使用双数组Trie进行创建检索。但是并没有加入双数组Trie的生成。所以CChineseAnalyzer的作用就是利用文件中保存的双数组Trie进行分词等。双数组Trie的作用就是一个庞大的状态机。
               一个最小的例子:有5个词语的双数组Trie。“中华” “中餐馆”“中午”“中华人民共和国”“人”。分析一句话“中华有56民族”。首先,确定状态机的表示值。这个值在Firtex中其实是存在coredict.pdat里的。我们重新定义一下。
“民” 1 == end
                 “午” 3== end
   "中"  2   "华"    4       人   5   民 6 共 7 和 8 国 9 ==end
                  餐      10      馆 11
            
比如,这句话“中华有56民族”,首先通过一个巨大的数组,得到“中”的状态-2。然后记录下来。得到“华” "华"会从2状态为基础进行,所以进入状态4。最后得到本句话,241。写入索引文件(当然还有许多其他信息)。

如果有人查找"中",2命中,有人查找"中华",4命中,直接通过数字查找,速度相当的快。

所以词语的量是比较少的,一旦词汇量上去的,双数组Trie复杂程度就直线增长。

结论:
所以Firtex是一个非常灵活,有效率的系统,适合做文件查找。但不适合文件标注或自然语言理解的开发。      

posted @ 2007-05-22 18:16 vcommon 阅读(1048) | 评论 (0)编辑 收藏

简介

          这篇文章解释了如何将使用DirectShow的应用程序转向使用vista上的Digital Media API,即Media Foundation.
  本文假设你已经非常熟悉DirectShow。并且本文并不讲述Media Foundation.

对比Media Foundation 和DirectShow

         我们已经跨入了对高清数字媒体时代。未来的数字高清将无处不在。但是他非常需要健壮的保护,而这是当前的数字媒体平台所不具备的。Media Fundation就是为了这个而存在。
        让我们审视高清数字,这个平台需要很有弹性,便于从小故障下恢复。需要考虑大量的不同品质的video 和audio.Media Foundation就是为了这个而存在。比如,支持下一代的HD技术:
  1:DirectX 视频加速(DXVA) 2.0提供了比DXVA1.0更高效率的视频加速,更稳定,最新的视频解码能力,和扩展的硬件视频加速。在DXVA2.0下,windows可以直接处理某些高清内容,并容易错误恢复。
2:Color-space能得以保存在整个视频处理流程中,所以中途可以无转换损失,用户可以享受到高逼真的画质。这个也能减少CPU等消耗。
3:增强的视频渲染器(enchanced video render EVR)增强了视频处理和时钟等。

        让我们研究一下文件保护,在用户购买了一部电影之后,他可以把电影传到他的某个设备上(一些设备支持直接在播放的时候录制),这个过程中会有多种保护模式,购买后的使用保护,播放时防录制保护,复制保护,如果某一个保护没有正确完成,就会使整套保护没有了意义。所以这需要有一个无缝的平台去相互协作。Media Foundation就是为了这个而存在。
        最后,让我们来总览一下DirectShow. DirectShow的API对这些数字高清媒体的应用程序确实是非常通用的,万能的,但是,DirectShow作为一个10多年的老技术而言已经力不从心了。比如:
   1:流程是静态static的,所以实现动态的Graph和Major format change是非常困难的。
  2:DirectShow filter的线程模型是非常复杂的,要完全理解并永不出错是太困难了。
  3:DirectShow filter只能用于DirectShow。
  4:DirectShow不支持文件保护。
  作为DirectShow的接替者,Media Foundation出现了,他不会马上替代DirectShow,作为第一步,他将在vista上慢慢展露他的影响。
  但是目前为止,Media Foundation只能在媒体保护(Proteced media process))方面大施手脚,还未向DirectShow进行足够的扩展和替代。


Appendix: Feature Comparisons

The following table compares the features of Media Foundation with those of DirectShow.

Feature
group
Feature Media
Foundation
DirectShow
Basic functionality Audio and video rendering Yes Yes
  Event notification Yes Yes
  Device enumeration No Yes
  Component enumeration Yes Yes
  Synchronization to reference clock Yes Yes
  Seeking Yes Yes
  Improved stress resilience Yes No
Content protection Component validation Yes No
  Content protection policy negotiation Yes No
  Interoperability between content protection technologies Yes No
  Protection against kernel-mode and user-mode threats Yes No
  Component revocation and renewal Yes No
  Video output protection management Yes Yes
Media tasks Audio capture No Yes
  Video capture No Yes
  Video editing No Yes
  DVD playback and navigation No Yes
  MPEG-2 support No Yes
  ASF support No Yes
  TV technologies No Yes
  Stream buffer engine No Yes
  Encoder API No Yes
Video renderer Substream mixing using per-pixel or planar alpha blending Yes Yes
  Customizable video composition No Yes
  Support for custom presenters Yes Yes
  Windowless rendering Yes Yes
  Multimonitor support Yes Yes
  DXVA Yes Yes
  DirectDraw exclusive mode Yes Yes
  Backward compatibility with existing applications Yes Yes
  Accurate frame stepping Yes Yes
  Alpha blending of image data Yes Yes
  Glitch resilience Yes No
  Enhanced video fidelity Yes No
  Enhanced content protection robustness Yes No
  Standalone use Yes No
  Standalone mixing component Yes No
Transforms (MFT or DMO) Synchronous data processing Yes Yes
  Simple programming model Yes Yes
  Standalone use Yes Yes
  Multiple inputs and multiple outputs Yes Yes
  Dynamic number of streams Yes No
  Access to sample-level metadata Yes No
  In-place processing Yes Yes
  Dynamic format changes Yes No
  Quality adjustment Yes No
  Rate change Yes No

The following table compares the features of Media Foundation with those of the Windows Media Format SDK.

Feature
group
Feature Media
Foundation
Format SDK
ASF file features Audio and video streams Yes Yes
  Image streams No Yes
  Arbitrary streams (text, file, Web, custom data) No Yes
  Script commands No Yes
  Data unit extensions Yes Yes
  SMPTE time code support No Yes
  Mutual exclusion Yes Yes
  Stream prioritization Yes Yes
  Bandwidth sharing No Yes
  Indexes Yes Yes
  Markers Yes Yes
  Multiple bit rate stream Yes Yes
  Multiple language support Yes Yes
Codec features CBR encoding Yes Yes
  VBR encoding Yes Yes
  Two-pass encoding Yes Yes
  High-resolution audio support Yes Yes
  Low delay audio Yes Yes
  S/PDIF audio output Yes Yes
  Video image Yes Yes
  Device conformance template Yes Yes
  Video complexity settings Yes Yes
  Frame interpolation Yes Yes
  DirectX Video Acceleration Yes Yes
File writing Video resizing Yes Yes
  Color space conversion Yes Yes
  Audio resampling Yes Yes
  ASF file sink Yes Yes
  Network sinks No Yes
  Push sinks No Yes
  Watermarking support No Yes
  Input formats, input settings, and data unit extensions Yes Yes
  WMA smart recompression No Yes
  Multichannel audio Yes Yes
File reading User-allocated sample support No Yes
  Synchronous reading No Yes
  Output format enumeration Yes Yes
  Multichannel audio Yes Yes
  MP3 support Yes Yes
  Network sources Yes Yes
Metadata ID3 support No Yes
  Custom metadata Yes Yes
Digital rights management Live DRM No Yes
  DRM Individualization Yes Yes
  Back up and restore DRM licenses Yes Yes
  View DRM attributes in the Metadata Editor Yes Yes
  Output protection levels Yes Yes
  License revocation Yes Yes
  Windows Media DRM for Network Devices Yes Yes
  Secure Audio Path No Yes
  Playlist burning Yes Yes
  Third-party transcription support Yes No
  Local license issuance Yes No
  Enhanced Windows Media DRM renewability Yes No


posted @ 2007-04-29 13:21 vcommon 阅读(7143) | 评论 (3)编辑 收藏

WPF

WPF是在D3D....之上的一层,所以试图使用WPF建立特殊效果必须考虑, 效果要短小精悍.
WPF是在开发效率和程序效率的一种平衡.
使用WPF构造复杂效果是没有意义的.

posted @ 2007-04-25 14:50 vcommon 阅读(343) | 评论 (0)编辑 收藏

1:Download Windows XP Service Pack 2 Support Tools from microsoft web site or from xp install CD.
2:打开控制面板,系统,高级,启动与故障恢复,设置,小内存转储,minidump.
3:coding to test(using vista SDK and unicode and link with Dbghelp.lib)(see code 1):(reference MSDN-
DirectX SDK (February 200...Technical Articles Crash Dump Analysis)
4:got file-Local Settings\Temp\AppName\v1.0-20070324-183348-684-2388.dmp only 507K size.
5:using dumpchk v1.0-20070324-183348-684-2388.dmp to check the file.(got debugclient cannot open dumpfile  0x80070003 error,so I change the dump file to c:\APPNAME.)(for reference--There must be a paging file configured on the system boot partition.  If you have changed the paging file location to a different drive letter then a memory dump cannot be saved).
6:see dumpcheck details as code2(so the file is correct):
7:anasyis the dump file. Open Visual Studio --Select File->Open->Project --Select the minidump file --Run the debugger
8:see the crash position-see picture1

~code1:
         #include <dbghelp.h>
         #include <shellapi.h>
         #include <shlobj.h>
         #include <strsafe.h>
         int GenerateDump(EXCEPTION_POINTERS* pExceptionPointers)
         {
             BOOL bMiniDumpSuccessful;
    WCHAR szPath[MAX_PATH];
    WCHAR szFileName[MAX_PATH];
    WCHAR* szAppName = L"AppName";
    WCHAR* szVersion = L"v1.0";
    DWORD dwBufferSize = MAX_PATH;
    HANDLE hDumpFile;
    SYSTEMTIME stLocalTime;
    MINIDUMP_EXCEPTION_INFORMATION ExpParam;
    GetLocalTime( &stLocalTime );
    GetTempPath( dwBufferSize, szPath );
    StringCchPrintf( szFileName, MAX_PATH, L"%s%s", szPath, szAppName );
    CreateDirectory( szFileName, NULL );
    StringCchPrintf( szFileName, MAX_PATH, L"%s%s\\%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp",
               szPath, szAppName, szVersion,
               stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay,
               stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond,
               GetCurrentProcessId(), GetCurrentThreadId());
    hDumpFile = CreateFile(szFileName, GENERIC_READ|GENERIC_WRITE,
                FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
    ExpParam.ThreadId = GetCurrentThreadId();
    ExpParam.ExceptionPointers = pExceptionPointers;
    ExpParam.ClientPointers = TRUE;
    bMiniDumpSuccessful = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
                    hDumpFile, MiniDumpWithDataSegs, &ExpParam, NULL, NULL);
    return EXCEPTION_EXECUTE_HANDLER;
}
void SomeFunction()
{
    __try
    {
        int *pBadPtr = NULL;
        *pBadPtr = 0;
    }
    __except(GenerateDump(GetExceptionInformation()))
    {
    }
}
void CdumptestDlg::OnBnClickedButton1()
{
 // TODO: Add your control notification handler code here
 SomeFunction();
}



~code2:
H:\Program Files\Support Tools>dumpchk C:\AppName\v1.0-20070324-190603-3984-2932
.dmp
Loading dump file C:\AppName\v1.0-20070324-190603-3984-2932.dmp
----- User Mini Dump Analysis

MINIDUMP_HEADER:
Version         A793 (5128)
NumberOfStreams 8
Flags 1

Streams:
Stream 0: type ThreadListStream (3), size 00000064, RVA 00000178
Stream 1: type ModuleListStream (4), size 00000BD4, RVA 000001DC
  28 modules
  RVA 000001E0, 00400000 - 00411000: 'h:\documents and settings\peter\my documen
ts\visual studio 2005\Projects\dumptest\debug\dumptest.exe'
  RVA 0000024C, 7c920000 - 7c9b4000: 'H:\WINDOWS\system32\ntdll.dll'
  RVA 000002B8, 7c800000 - 7c91c000: 'H:\WINDOWS\system32\kernel32.dll'
  RVA 00000324, 68d60000 - 68e01000: 'H:\WINDOWS\system32\dbghelp.dll'
  RVA 00000390, 77be0000 - 77c38000: 'H:\WINDOWS\system32\msvcrt.dll'
  RVA 000003FC, 77bd0000 - 77bd8000: 'H:\WINDOWS\system32\version.dll'
  RVA 00000468, 77da0000 - 77e49000: 'H:\WINDOWS\system32\advapi32.dll'
  RVA 000004D4, 77e50000 - 77ee1000: 'H:\WINDOWS\system32\rpcrt4.dll'
  RVA 00000540, 782e0000 - 7852b000: 'H:\WINDOWS\WinSxS\x86_Microsoft.VC80.Debug
MFC_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_c8452471\mfc80ud.dll'
  RVA 000005AC, 10200000 - 10320000: 'H:\WINDOWS\WinSxS\x86_Microsoft.VC80.Debug
CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll'
  RVA 00000618, 77ef0000 - 77f37000: 'H:\WINDOWS\system32\gdi32.dll'
  RVA 00000684, 77d10000 - 77d9f000: 'H:\WINDOWS\system32\user32.dll'
  RVA 000006F0, 77f40000 - 77fb6000: 'H:\WINDOWS\system32\shlwapi.dll'
  RVA 0000075C, 77180000 - 77283000: 'H:\WINDOWS\WinSxS\x86_Microsoft.Windows.Co
mmon-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll'
  RVA 000007C8, 76300000 - 7631d000: 'H:\WINDOWS\system32\imm32.dll'
  RVA 00000834, 62c20000 - 62c29000: 'H:\WINDOWS\system32\lpk.dll'
  RVA 000008A0, 73fa0000 - 7400b000: 'H:\WINDOWS\system32\usp10.dll'
  RVA 0000090C, 5d360000 - 5d36a000: 'H:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFCLO
C_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_3415f6d0\mfc80CHS.dll'
  RVA 00000978, 5a800000 - 5a81e000: 'I:\Media-Tools\Software\Windows'
  RVA 000009E4, 770f0000 - 7717c000: 'H:\WINDOWS\system32\oleaut32.dll'
  RVA 00000A50, 76990000 - 76acd000: 'H:\WINDOWS\system32\ole32.dll'
  RVA 00000ABC, 74680000 - 746cb000: 'H:\WINDOWS\system32\MSCTF.dll'
  RVA 00000B28, 10000000 - 10004000: 'H:\Program Files\Unlocker\UnlockerHook.dll
'
  RVA 00000B94, 7d590000 - 7dd82000: 'H:\WINDOWS\system32\shell32.dll'
  RVA 00000C00, 73640000 - 7366e000: 'H:\WINDOWS\system32\MSCTFIME.IME'
  RVA 00000C6C, 5adc0000 - 5adf7000: 'H:\WINDOWS\system32\uxtheme.dll'
  RVA 00000CD8, 01000000 - 01019000: 'H:\Program Files\Rising\AntiSpyware\ieprot
.dll'
  RVA 00000D44, 76bc0000 - 76bcb000: 'H:\WINDOWS\system32\psapi.dll'
Stream 2: type MemoryListStream (5), size 000001F4, RVA 00002538
  31 memory ranges
  range#    Address      Size
       0    7c92eb14   00000100
       1    00409000   00000594
       2    7c99c000   000049e0
       3    7c883000   000043a0
       4    68df0000   00004a70
       5    77c2d000   000067c8
       6    77bd5000   000002fc
       7    77e16000   00004528
       8    77eda000   00000e90
       9    784f9000   000071a4
      10    1030e000   00006acc
      11    77f33000   00000f60
      12    77d70000   00001180
      13    77fad000   00000ff8
      14    77212000   00000a50
      15    76316000   0000088c
      16    62c26000   000001d4
      17    73fe5000   0000f2c0
      18    5a817000   00000e6c
      19    5a819000   00000bbc
      20    77172000   00002038
      21    76ab6000   000069d4
      22    746c2000   000013dc
      23    10002000   00000424
      24    7d78d000   0001c170
      25    73668000   00000568
      26    5adf1000   00000e78
      27    0100f000   00001690
      28    76bc5000   000031e8
      29    0012e198   00001e68
      30    0112fe98   00000168
Stream 3: type ExceptionStream (6), size 000000A8, RVA 000000D0
Stream 4: type SystemInfoStream (7), size 00000038, RVA 00000080
Stream 5: type ??? (15), size 00000018, RVA 000000B8
Stream 6: type UnusedStream (0), size 00000000, RVA 00000000
Stream 7: type UnusedStream (0), size 00000000, RVA 00000000


Windows XP Version 2600 (Service Pack 2) UP Free x86 compatible
Debug session time: Sat Mar 24 19:06:03 2007
System Uptime: not available
The call to LoadLibrary(ext) failed with error 2.
Please check your debugger configuration and/or network access
PEB NULL...
Finished dump check

~pic1

posted @ 2007-03-24 19:23 vcommon 阅读(605) | 评论 (0)编辑 收藏

                                                   从OutputDebugString的泥潭撤退
         曾几何时,非常习惯使用OutputDebugString和DbgView去查找问题,然而大量的log让人眼花缭乱.
OutputDebugString介绍:
OutputDebugString在每次调用时会使进程切换进程上下文.
WaitForDebugEvent的返回值DEBUG_EVENT = OUTPUT_DEBUG_STRING_INFO.
这意味着进程暂停,然后Debugger从进程外的某个地址读取进程内的信息.
所以即使是Release Build,其实也运行和Debug基本相同的状态.

由于这用方法有很多优缺点,所以被人诟病:
而且对于有些第三方的代码或者自动生成的,例如把Trace全改成OutputDebugString,都要手工处理,很是头疼.在维护了很久大量的log之后,软件移植或重构,有些log的意义就没有了,又要全部重新维护。

   方法就是利用HOOK去把所有的OutputDebugString和AtlTrace...全部转到自己的函数里去。
缺点是并不稳定。

posted @ 2007-03-13 18:04 vcommon 阅读(7999) | 评论 (0)编辑 收藏

仅列出标题
共4页: 1 2 3 4