C++/FFMPEG 中的宏
Macros in C++ / FFMPEG
我是 C++ 的新手,我正在尝试为 FFMPEG 构建自定义编解码器。我试图将它基于 PCM 但只有一种类型。我已经 运行 变成了一个宏,但我不知道宏在编译后会变成什么。
宏看起来像这样:
#define ENCODE_PLANAR(type, endian, dst, n, shift, offset) \
n /= avctx->channels; \
for (c = 0; c < avctx->channels; c++) { \
int i; \
samples_ ## type = (const type *) frame->extended_data[c]; \
for (i = n; i > 0; i--) { \
register type v = (*samples_ ## type++ >> shift) + offset; \
bytestream_put_ ## endian(&dst, v); \
} \
}
如果 endian = byte 且 type = uint8_t,samples_ 声明行和 bytestream_put 行是否等于我在下面放置的内容?
uint8_t samples_ = (const uint8_t *) frame->extended_data[c];
bytestream_put_byte(&dst, v);
我觉得这很混乱,我不确定这是否正确。
FFmpeg 的 pcm.c 文件中使用的这个 C 宏(不是 C++),pcm_encode_frame
函数。 PCM 音频帧(8、16、24 或 32 位)以各种通道配置和字节序存储,以打包(交错)或平面格式存储。这个宏(在文件中清楚地看到)用于将缓冲区填充为平面格式。
示例扩展如下(对于 AV_CODEC_ID_PCM_S16LE_PLANAR):
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
int i;
samples_int16_t = (const int16_t *) frame->extended_data[c];
for (i = n; i > 0; i--) {
register int16_t v = (*samples_int16_t++ >> 0) + 0;
bytestream_put_le16(&dst, v);
}
}
希望对您有所帮助。
我是 C++ 的新手,我正在尝试为 FFMPEG 构建自定义编解码器。我试图将它基于 PCM 但只有一种类型。我已经 运行 变成了一个宏,但我不知道宏在编译后会变成什么。 宏看起来像这样:
#define ENCODE_PLANAR(type, endian, dst, n, shift, offset) \
n /= avctx->channels; \
for (c = 0; c < avctx->channels; c++) { \
int i; \
samples_ ## type = (const type *) frame->extended_data[c]; \
for (i = n; i > 0; i--) { \
register type v = (*samples_ ## type++ >> shift) + offset; \
bytestream_put_ ## endian(&dst, v); \
} \
}
如果 endian = byte 且 type = uint8_t,samples_ 声明行和 bytestream_put 行是否等于我在下面放置的内容?
uint8_t samples_ = (const uint8_t *) frame->extended_data[c];
bytestream_put_byte(&dst, v);
我觉得这很混乱,我不确定这是否正确。
FFmpeg 的 pcm.c 文件中使用的这个 C 宏(不是 C++),pcm_encode_frame
函数。 PCM 音频帧(8、16、24 或 32 位)以各种通道配置和字节序存储,以打包(交错)或平面格式存储。这个宏(在文件中清楚地看到)用于将缓冲区填充为平面格式。
示例扩展如下(对于 AV_CODEC_ID_PCM_S16LE_PLANAR):
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
int i;
samples_int16_t = (const int16_t *) frame->extended_data[c];
for (i = n; i > 0; i--) {
register int16_t v = (*samples_int16_t++ >> 0) + 0;
bytestream_put_le16(&dst, v);
}
}
希望对您有所帮助。