类型定义的方式
有些类型是这样定义的:
typedef struct AVFrame {
FF_COMMON_FRAME
} AVFrame;
#define FF_COMMON_FRAME \
/**\
* pointer to the picture planes.\
* this might be different from the first allocated byte\
* - encoding: \
* - decoding: \
*/\
uint8_t *data[4];\
int linesize[4];\
/**\
* pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
* this isn 't used by lavc unless the default get/release_buffer() is used\
* - encoding: \
* - decoding: \
*/\
uint8_t *base[4];\
/**\
* 1 -> keyframe, 0-> not\
* - encoding: set by lavc\
* - decoding: set by lavc\
*/\
int key_frame;\
\
/**\
* picture type of the frame, see ?_TYPE below.\
* - encoding: set by lavc for coded_picture (and set by user for input)\
* - decoding: set by lavc\
*/\
int pict_type;\
请问为什么这样写?这样写有什么好处?谢谢!
[解决办法]
FF_COMMON_FRAME
这样可能 FF_COMMON_FRAME 是经常被用到的一部分定义,
那么使用 define 独立开来,
比较方便。
当然你也可以使用别的方式包装。