Author Topic: C Macro to translate  (Read 272 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1420
    • EditMasm
C Macro to translate
« on: August 13, 2020, 12:20:40 AM »
Hello,
I need help to translate two C macros providing media GUID
Quote
;----------------- manuel translation of a sort of MACRO -------------------------------------------
;#define DEFINE_MEDIATYPE_GUID(name, format) \
;    DEFINE_GUID(name,                       \
;    format, 0x0000, 0x0010,   0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);     11 data
;--------------------------- Manual soluce  sample ------------------------------------------------
;declare
; sMFVideoFormat_RGB32 TEXTEQU  <{D3DFMT_X8R8G8B8h,0000h,010h,{080h,000h,000h,0AAh,00h,038h,09bh,071h}}>
; en data
; MFVideoFormat_RGB32 GUID sMFVideoFormat_RGB32
;-------------------------------- autre macro -------------------------------------------------------------
;#define FCC(ch4) ((((DWORD)(ch4) & 0xFF) << 24) |     \
;                 (((DWORD)(ch4) & 0xFF00) << 8) |    \
;                  (((DWORD)(ch4) & 0xFF0000) >> 8) |  \
;                  (((DWORD)(ch4) & 0xFF000000) >> 24))
;---------------------------------- a traduire ------------------------------------------------------------------------
comment µ
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Base,      0x00000000 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_RGB32,     D3DFMT_X8R8G8B8 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_ARGB32,    D3DFMT_A8R8G8B8 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_RGB24,     D3DFMT_R8G8B8 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_RGB555,    D3DFMT_X1R5G5B5 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_RGB565,    D3DFMT_R5G6B5 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_RGB8,      D3DFMT_P8 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_L8,        D3DFMT_L8 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_L16,       D3DFMT_L16 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_D16,       D3DFMT_D16 );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_AI44,      FCC('AI44') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_AYUV,      FCC('AYUV') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_YUY2,      FCC('YUY2') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_YVYU,      FCC('YVYU') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_YVU9,      FCC('YVU9') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_UYVY,      FCC('UYVY') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_NV11,      FCC('NV11') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_NV12,      FCC('NV12') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_YV12,      FCC('YV12') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_I420,      FCC('I420') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_IYUV,      FCC('IYUV') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Y210,      FCC('Y210') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Y216,      FCC('Y216') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Y410,      FCC('Y410') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Y416,      FCC('Y416') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Y41P,      FCC('Y41P') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Y41T,      FCC('Y41T') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_Y42T,      FCC('Y42T') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_P210,      FCC('P210') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_P216,      FCC('P216') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_P010,      FCC('P010') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_P016,      FCC('P016') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_v210,      FCC('v210') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_v216,      FCC('v216') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_v410,      FCC('v410') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_MP43,      FCC('MP43') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_MP4S,      FCC('MP4S') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_M4S2,      FCC('M4S2') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_MP4V,      FCC('MP4V') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_WMV1,      FCC('WMV1') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_WMV2,      FCC('WMV2') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_WMV3,      FCC('WMV3') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_WVC1,      FCC('WVC1') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_MSS1,      FCC('MSS1') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_MSS2,      FCC('MSS2') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_MPG1,      FCC('MPG1') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_DVSL,      FCC('dvsl') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_DVSD,      FCC('dvsd') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_DVHD,      FCC('dvhd') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_DV25,      FCC('dv25') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_DV50,      FCC('dv50') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_DVH1,      FCC('dvh1') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_DVC,       FCC('dvc ') );
DEFINE_MEDIATYPE_GUID( MFVideoFormat_H264,      FCC('H264') );  // assume MFVideoFormat_H264 is frame

Searching a little,there is more to translate.
Those GUID are needed to use the Media foundation,https://docs.microsoft.com/en-us/windows/win32/medfound/how-to-play-unprotected-media-files
in the attachment is a working sample of what can be done (microsoft c++ sample)
pass it this URL http://direct.franceculture.fr/live/franceculture-midfi.mp3
Fa is a musical note to play with CL

guga

  • Member
  • *****
  • Posts: 1346
  • Assembly is a state of art.
    • RosAsm
Re: C Macro to translate
« Reply #1 on: August 13, 2020, 01:03:32 AM »
MFVideoFormat_Base    Guid    00000000-0000-0010-8000-00aa00389b71
MFVideoFormat_RGB32    Guid    00000016-0000-0010-8000-00aa00389b71
MFVideoFormat_ARGB32    Guid    00000015-0000-0010-8000-00aa00389b71
MFVideoFormat_RGB24    Guid    00000014-0000-0010-8000-00aa00389b71
MFVideoFormat_RGB555    Guid    00000018-0000-0010-8000-00aa00389b71
MFVideoFormat_RGB565    Guid    00000017-0000-0010-8000-00aa00389b71
MFVideoFormat_RGB8    Guid    00000029-0000-0010-8000-00aa00389b71
MFVideoFormat_L8    Guid    00000032-0000-0010-8000-00aa00389b71
MFVideoFormat_L16    Guid    00000051-0000-0010-8000-00aa00389b71
MFVideoFormat_D16    Guid    00000050-0000-0010-8000-00aa00389b71
MFVideoFormat_AI44    Guid    34344941-0000-0010-8000-00aa00389b71
MFVideoFormat_AYUV    Guid    56555941-0000-0010-8000-00aa00389b71
MFVideoFormat_YUY2    Guid    32595559-0000-0010-8000-00aa00389b71
MFVideoFormat_YVYU    Guid    55595659-0000-0010-8000-00aa00389b71
MFVideoFormat_YVU9    Guid    39555659-0000-0010-8000-00aa00389b71
MFVideoFormat_H264    Guid    34363248-0000-0010-8000-00aa00389b71
MFVideoFormat_UYVY    Guid    59565955-0000-0010-8000-00aa00389b71

The others you can search here. No need for translation, just paste the name of the guid and set the checkboxes of the site to "Index+Name+Type+Value" and voilá  :thumbsup: :thumbsup: :thumbsup:

https://www.magnumdb.com/search?q=MFVideoFormat_UYVY


Once, you have done, please post for us too  :azn: :azn: :azn:
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

nidud

  • Member
  • *****
  • Posts: 1999
    • https://github.com/nidud/asmc
Re: C Macro to translate
« Reply #2 on: August 13, 2020, 01:52:04 AM »
There are 3 conditions for this:
- define as external (use uuid.lib)
- define as data (build uuid.lib)
- define as string (no lib (-pe))

DEFINE_GUID macro id, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8
if defined(__PE__) or defined(__GUID__)
_&id& equ <{l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}>
elseifdef INITGUID
echo id GUID {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
else
externdef id:GUID
endif
    exitm<>
    endm

DEFINE_OLEGUID macro id, l, w1, w2
    exitm<DEFINE_GUID(id, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)>
    endm

Define as a string: DEFINE_IIDX(IMSVidFilePlayback, "37B03539-A4C8-11d2-B634-00C04F79498E")

DEFINE_IIDX macro name, x
    DEFINE_GUID(IID_&name&, \
   @CatStr(<0x>, @SubStr(x, 2,8)), \
   @CatStr(<0x>, @SubStr(x,11,4)), \
   @CatStr(<0x>, @SubStr(x,16,4)), \
   @CatStr(<0x>, @SubStr(x,21,2)), \
   @CatStr(<0x>, @SubStr(x,23,2)), \
   @CatStr(<0x>, @SubStr(x,26,2)), \
   @CatStr(<0x>, @SubStr(x,28,2)), \
   @CatStr(<0x>, @SubStr(x,30,2)), \
   @CatStr(<0x>, @SubStr(x,32,2)), \
   @CatStr(<0x>, @SubStr(x,34,2)), \
   @CatStr(<0x>, @SubStr(x,36,2)))
   exitm<>
   endm


TouEnMasm

  • Member
  • *****
  • Posts: 1420
    • EditMasm
Re: C Macro to translate
« Reply #3 on: August 14, 2020, 01:41:51 AM »

Thanks for anwers.
I will try to made with all that.
I have try to made c++ translate this for me,but i have not the correct syntax.

for example:
Quote
const IID MFBase = MFVideoFormat_RGB24;

LPCSTR  phrase[300];
                     
int cdecl wmain ( int argc, char *argv[ ], char *envp[ ] )
{   
   
   StringFromGUID2(MFBase,(LPOLESTR)phrase,sizeof(phrase));
    printf(*phrase);
   // copier coller ici
   _getch();
answer by link   error LNK2019: symbole externe non r‚solu _MFVideoFormat_RGB24


Fa is a musical note to play with CL

TouEnMasm

  • Member
  • *****
  • Posts: 1420
    • EditMasm
Re: C Macro to translate
« Reply #4 on: August 14, 2020, 06:23:37 AM »

Here the soluce i have used in c++ and command line,less difficult than VS.

VC command line: /c /FA /Gm- /GS- /Ox /MD

Quote
MFVideoFormat_Base    {00000000-0000-0010-8000-00AA00389B71}
MFVideoFormat_RGB32    {00000016-0000-0010-8000-00AA00389B71}
MFVideoFormat_ARGB32    {00000015-0000-0010-8000-00AA00389B71}
MFVideoFormat_RGB24    {00000014-0000-0010-8000-00AA00389B71}
MFVideoFormat_RGB555    {00000018-0000-0010-8000-00AA00389B71}
MFVideoFormat_RGB565    {00000017-0000-0010-8000-00AA00389B71}
MFVideoFormat_RGB8    {00000029-0000-0010-8000-00AA00389B71}
MFVideoFormat_L8    {00000032-0000-0010-8000-00AA00389B71}
MFVideoFormat_L16    {00000051-0000-0010-8000-00AA00389B71}
MFVideoFormat_D16    {00000050-0000-0010-8000-00AA00389B71}
MFVideoFormat_AI44    {34344941-0000-0010-8000-00AA00389B71}
MFVideoFormat_AYUV    {56555941-0000-0010-8000-00AA00389B71}
MFVideoFormat_YUY2    {32595559-0000-0010-8000-00AA00389B71}
MFVideoFormat_YVYU    {55595659-0000-0010-8000-00AA00389B71}
MFVideoFormat_YVU9    {39555659-0000-0010-8000-00AA00389B71}
MFVideoFormat_UYVY    {59565955-0000-0010-8000-00AA00389B71}
MFVideoFormat_NV11    {3131564E-0000-0010-8000-00AA00389B71}
MFVideoFormat_NV12    {3231564E-0000-0010-8000-00AA00389B71}
MFVideoFormat_YV12    {32315659-0000-0010-8000-00AA00389B71}
MFVideoFormat_I420    {30323449-0000-0010-8000-00AA00389B71}
MFVideoFormat_IYUV    {56555949-0000-0010-8000-00AA00389B71}
MFVideoFormat_Y210    {30313259-0000-0010-8000-00AA00389B71}
MFVideoFormat_Y216    {36313259-0000-0010-8000-00AA00389B71}
MFVideoFormat_Y410    {30313459-0000-0010-8000-00AA00389B71}
MFVideoFormat_Y416    {36313459-0000-0010-8000-00AA00389B71}
MFVideoFormat_Y41P    {50313459-0000-0010-8000-00AA00389B71}
 MFVideoFormat_Y41T    {54313459-0000-0010-8000-00AA00389B71}
MFVideoFormat_Y42T    {54323459-0000-0010-8000-00AA00389B71}
MFVideoFormat_P210    {30313250-0000-0010-8000-00AA00389B71}
 MFVideoFormat_P216    {36313250-0000-0010-8000-00AA00389B71}
MFVideoFormat_P010    {30313050-0000-0010-8000-00AA00389B71}
MFVideoFormat_P016    {36313050-0000-0010-8000-00AA00389B71}
MFVideoFormat_v210    {30313276-0000-0010-8000-00AA00389B71}
MFVideoFormat_v216    {36313276-0000-0010-8000-00AA00389B71}
MFVideoFormat_v410    {30313476-0000-0010-8000-00AA00389B71}
MFVideoFormat_MP43    {3334504D-0000-0010-8000-00AA00389B71}
MFVideoFormat_MP4S    {5334504D-0000-0010-8000-00AA00389B71}
MFVideoFormat_M4S2    {3253344D-0000-0010-8000-00AA00389B71}
MFVideoFormat_MP4V    {5634504D-0000-0010-8000-00AA00389B71}
MFVideoFormat_WMV1    {31564D57-0000-0010-8000-00AA00389B71}
MFVideoFormat_WMV2    {32564D57-0000-0010-8000-00AA00389B71}
MFVideoFormat_WMV3    {33564D57-0000-0010-8000-00AA00389B71}
MFVideoFormat_WVC1    {31435657-0000-0010-8000-00AA00389B71}
MFVideoFormat_MSS1    {3153534D-0000-0010-8000-00AA00389B71}
MFVideoFormat_MSS2    {3253534D-0000-0010-8000-00AA00389B71}
MFVideoFormat_MPG1    {3147504D-0000-0010-8000-00AA00389B71}
MFVideoFormat_DVSL    {6C737664-0000-0010-8000-00AA00389B71}
MFVideoFormat_DVSD    {64737664-0000-0010-8000-00AA00389B71}
MFVideoFormat_DVHD    {64687664-0000-0010-8000-00AA00389B71}
MFVideoFormat_DV25    {35327664-0000-0010-8000-00AA00389B71}
MFVideoFormat_DV50    {30357664-0000-0010-8000-00AA00389B71}
MFVideoFormat_DVH1    {31687664-0000-0010-8000-00AA00389B71}
MFVideoFormat_DVC    {20637664-0000-0010-8000-00AA00389B71}
MFVideoFormat_H264    {34363248-0000-0010-8000-00AA00389B71}
MFVideoFormat_H265    {35363248-0000-0010-8000-00AA00389B71}
MFVideoFormat_MJPG    {47504A4D-0000-0010-8000-00AA00389B71}
MFVideoFormat_420O    {4F303234-0000-0010-8000-00AA00389B71}
MFVideoFormat_HEVC    {43564548-0000-0010-8000-00AA00389B71}
MFVideoFormat_HEVC_ES    {53564548-0000-0010-8000-00AA00389B71}
MFVideoFormat_VP80    {30385056-0000-0010-8000-00AA00389B71}
MFVideoFormat_VP90    {30395056-0000-0010-8000-00AA00389B71}
MFVideoFormat_ORAW    {5741524F-0000-0010-8000-00AA00389B71}

Fa is a musical note to play with CL