News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Translating C header

Started by Farabi, April 21, 2009, 03:15:10 AM

Previous topic - Next topic

Farabi

Is this
Quote
projectedTrainFaceMat->data.fl + i*offset
same with this?
Quote
projectedTrainFaceMat->data.fl[ i*offset]

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

h2incx cannot translate this, anyone know what this mean?
Quote
#define CV_SEQUENCE_FIELDS()                                              \
    CV_TREE_NODE_FIELDS(CvSeq);                                           \
    int       total;          /* Total number of elements.            */  \
    int       elem_size;      /* Size of sequence element in bytes.   */  \
    schar*    block_max;      /* Maximal bound of the last block.     */  \
    schar*    ptr;            /* Current write pointer.               */  \
    int       delta_elems;    /* Grow seq this many at a time.        */  \
    CvMemStorage* storage;    /* Where the seq is stored.             */  \
    CvSeqBlock* free_blocks;  /* Free blocks list.                    */  \
    CvSeqBlock* first;        /* Pointer to the first sequence block. */

typedef struct CvSeq
{
    CV_SEQUENCE_FIELDS()
}
CvSeq;
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm

This is a class definition,not translatable (c++)
For translate,you must identify what is each term.
In particular [CV_TREE_NODE_FIELDS(CvSeq)] ,Function ?,others are dword (data declare)
If CV_TREE_NODE_FIELDS contant,repeat structure ?!
/FA (c++ flat assembler ) can be of great help


Farabi


#define CV_TREE_NODE_FIELDS(node_type)                               \
    int       flags;             /* Miscellaneous flags.     */      \
    int       header_size;       /* Size of sequence header. */      \
    struct    node_type* h_prev; /* Previous sequence.       */      \
    struct    node_type* h_next; /* Next sequence.           */      \
    struct    node_type* v_prev; /* 2nd previous sequence.   */      \
    struct    node_type* v_next  /* 2nd next sequence.       */

/*
   Read/Write sequence.
   Elements can be dynamically inserted to or deleted from the sequence.
*/
#define CV_SEQUENCE_FIELDS()                                              \
    CV_TREE_NODE_FIELDS(CvSeq);                                           \
    int       total;          /* Total number of elements.            */  \
    int       elem_size;      /* Size of sequence element in bytes.   */  \
    schar*    block_max;      /* Maximal bound of the last block.     */  \
    schar*    ptr;            /* Current write pointer.               */  \
    int       delta_elems;    /* Grow seq this many at a time.        */  \
    CvMemStorage* storage;    /* Where the seq is stored.             */  \
    CvSeqBlock* free_blocks;  /* Free blocks list.                    */  \
    CvSeqBlock* first;       
#define CV_CONTOUR_FIELDS()  \
    CV_SEQUENCE_FIELDS()     \
    CvRect rect;             \
    int color;               \
    int reserved[3];

typedef struct CvContour
{
    CV_CONTOUR_FIELDS()
}
CvContour;



I need to find out how much byte the CvContour size it, this is so complicated.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Quote from: Farabi on May 19, 2009, 09:28:37 AM

#define CV_TREE_NODE_FIELDS(node_type)                               \
    int       flags;             /* Miscellaneous flags.     */      \
    int       header_size;       /* Size of sequence header. */      \
    struct    node_type* h_prev; /* Previous sequence.       */      \
    struct    node_type* h_next; /* Next sequence.           */      \
    struct    node_type* v_prev; /* 2nd previous sequence.   */      \
    struct    node_type* v_next  /* 2nd next sequence.       */

/*
   Read/Write sequence.
   Elements can be dynamically inserted to or deleted from the sequence.
*/
#define CV_SEQUENCE_FIELDS()                                              \
    CV_TREE_NODE_FIELDS(CvSeq);                                           \
    int       total;          /* Total number of elements.            */  \
    int       elem_size;      /* Size of sequence element in bytes.   */  \
    schar*    block_max;      /* Maximal bound of the last block.     */  \
    schar*    ptr;            /* Current write pointer.               */  \
    int       delta_elems;    /* Grow seq this many at a time.        */  \
    CvMemStorage* storage;    /* Where the seq is stored.             */  \
    CvSeqBlock* free_blocks;  /* Free blocks list.                    */  \
    CvSeqBlock* first;       
#define CV_CONTOUR_FIELDS()  \
    CV_SEQUENCE_FIELDS()     \
    CvRect rect;             \
    int color;               \
    int reserved[3];

typedef struct CvContour
{
    CV_CONTOUR_FIELDS()
}
CvContour;



I need to find out how much byte the CvContour size it, this is so complicated.

I simply translate it to this but does not work
Quote
CvContour struct
   flags dword 0
   header_size dword 0
   h_prev dword 0
   h_next dword 0
   v_prev dword 0
   v_next dword 0
   total dword 0
   elem_size dword 0
   block_max dword 0
   _ptr dword 0
   delta_elems dword 0
   storage dword 0
   free_blocks dword 0
   first dword 0
   rect RECT <0>
   color dword 0
   reserved dword 3 dup (0)
CvContour ends
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

bruce1948






Quote from: Farabi on May 19, 2009, 09:30:56 AM
Quote from: Farabi on May 19, 2009, 09:28:37 AM

#define CV_TREE_NODE_FIELDS(node_type)                               \
    int       flags;             /* Miscellaneous flags.     */      \
    int       header_size;       /* Size of sequence header. */      \
    struct    node_type* h_prev; /* Previous sequence.       */      \
    struct    node_type* h_next; /* Next sequence.           */      \
    struct    node_type* v_prev; /* 2nd previous sequence.   */      \
    struct    node_type* v_next  /* 2nd next sequence.       */

/*
   Read/Write sequence.
   Elements can be dynamically inserted to or deleted from the sequence.
*/
#define CV_SEQUENCE_FIELDS()                                              \
    CV_TREE_NODE_FIELDS(CvSeq);                                           \
    int       total;          /* Total number of elements.            */  \
    int       elem_size;      /* Size of sequence element in bytes.   */  \
    schar*    block_max;      /* Maximal bound of the last block.     */  \
    schar*    ptr;            /* Current write pointer.               */  \
    int       delta_elems;    /* Grow seq this many at a time.        */  \
    CvMemStorage* storage;    /* Where the seq is stored.             */  \
    CvSeqBlock* free_blocks;  /* Free blocks list.                    */  \
    CvSeqBlock* first;       
#define CV_CONTOUR_FIELDS()  \
    CV_SEQUENCE_FIELDS()     \
    CvRect rect;             \
    int color;               \
    int reserved[3];

typedef struct CvContour
{
    CV_CONTOUR_FIELDS()
}
CvContour;



I need to find out how much byte the CvContour size it, this is so complicated.

I simply translate it to this but does not work
Quote
CvContour struct
   flags dword 0
   header_size dword 0
   h_prev dword 0
   h_next dword 0
   v_prev dword 0
   v_next dword 0
   total dword 0
   elem_size dword 0
   block_max dword 0
   _ptr dword 0
   delta_elems dword 0
   storage dword 0
   free_blocks dword 0
   first dword 0
   rect RECT <0>
   color dword 0
   reserved dword 3 dup (0)
CvContour ends





These are C macros and some of them take parameters. The first one takes a parameter of node_type and sets h_prev etc to be pointers to the structure which is passed as the macro parameter. You really have to find out where the macros are used and what the parameter passed to them is.  I suspect that they may be used in the code to put items on the stack. Not an easy task to convert this.

bruce1948

I've looked at this again and are you sure that a CvRect is the same as a standard RECT?

Farabi

Quote from: bruce1948 on May 20, 2009, 06:55:43 PM
I've looked at this again and are you sure that a CvRect is the same as a standard RECT?
Yep I sure, the only different is there is no x2 and y2 but width and height.
After an hours trying I think the fist 6 parameter is right, but the other is unknown, I guess that is enough because I only need that first 6 parameter.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

bruce1948

Yeas the first 6 look OK to me.