Here is an example, we have a structure named Slice, the function like ‘get_direct_motion_vectors’ should really be put inside this structure. So we can use ‘Slice->get_direct_motion_vectors(…)’instead of just call that function. So put a function pointer inside the structure is a good one:
typedef struct slice
{
int picture_id;
void (*get_direct_motion_vectors) (Macroblock *currMB);
...
}Slice;
// Usage:
(*currSlice)->get_direct_motion_vector = Get_MV;
// where ‘Get_MV’ is defined in another .h file: mv_search.h
extern void Get_MV(Macroblock *currMB);
// and it is implemented in .c file: mv_search.c
void Get_MV(Macroblock *currMB) { . . .}


0 comments:
Post a Comment