Home | History | Annotate | Download | only in Common
      1 // RegisterCodec.h
      2 
      3 #ifndef __REGISTER_CODEC_H
      4 #define __REGISTER_CODEC_H
      5 
      6 #include "../Common/MethodId.h"
      7 #include "../ICoder.h"
      8 
      9 typedef void * (*CreateCodecP)();
     10 struct CCodecInfo
     11 {
     12   CreateCodecP CreateDecoder;
     13   CreateCodecP CreateEncoder;
     14   CMethodId Id;
     15   const wchar_t *Name;
     16   UInt32 NumInStreams;
     17   bool IsFilter;
     18 };
     19 
     20 void RegisterCodec(const CCodecInfo *codecInfo) throw();
     21 
     22 #define REGISTER_CODEC_NAME(x) CRegisterCodec ## x
     23 
     24 #define REGISTER_CODEC(x) struct REGISTER_CODEC_NAME(x) { \
     25     REGISTER_CODEC_NAME(x)() { RegisterCodec(&g_CodecInfo); }}; \
     26     static REGISTER_CODEC_NAME(x) g_RegisterCodec;
     27 
     28 #define REGISTER_CODECS_NAME(x) CRegisterCodecs ## x
     29 #define REGISTER_CODECS(x) struct REGISTER_CODECS_NAME(x) { \
     30     REGISTER_CODECS_NAME(x)() { for (unsigned i = 0; i < ARRAY_SIZE(g_CodecsInfo); i++) \
     31     RegisterCodec(&g_CodecsInfo[i]); }}; \
     32     static REGISTER_CODECS_NAME(x) g_RegisterCodecs;
     33 
     34 
     35 struct CHasherInfo
     36 {
     37   IHasher * (*CreateHasher)();
     38   CMethodId Id;
     39   const wchar_t *Name;
     40   UInt32 DigestSize;
     41 };
     42 
     43 void RegisterHasher(const CHasherInfo *hasher) throw();
     44 
     45 #define REGISTER_HASHER_NAME(x) CRegisterHasher ## x
     46 
     47 #define REGISTER_HASHER(x) struct REGISTER_HASHER_NAME(x) { \
     48     REGISTER_HASHER_NAME(x)() { RegisterHasher(&g_HasherInfo); }}; \
     49     static REGISTER_HASHER_NAME(x) g_RegisterHasher;
     50 
     51 #endif
     52