FFmpeg
文件| 功能
库重新采样

音频重采样、样本格式转换和混音库。 更多的...

文件

file  swresample.h
 

功能

const AVClass * swr_get_class(无效)
 获取SwrContext的AVClass。 更多的...
 

选项常量

These constants are used for the AVOptions interface for lswr.

enum  SwrDitherType {
  SWR_DITHER_NONE = 0, SWR_DITHER_RECTANGULAR, SWR_DITHER_TRIANGULAR, SWR_DITHER_TRIANGULAR_HIGHPASS,
  SWR_DITHER_NS = 64, SWR_DITHER_NS_LIPSHITZ, SWR_DITHER_NS_F_WEIGHTED, SWR_DIT_NS_MODIFIED_ E_WEIGHTED ,
  SWR_DITHER_NS_IMPROVED_E_WEIGHTED, SWR_DITHER_NS_SHIBATA, SWR_DITHER_NS_LOW_SHIBATA, SWR_DITHER_NS_HIGH_SHIBATA,
  SWR_DITHER_NB
}
 抖动算法。 更多的...
 
enum  SwrEngine { SWR_ENGINE_SWR , SWR_ENGINE_SOXR , SWR_ENGINE_NB }
 重新采样引擎。 更多的...
 
enum  SwrFilterType { SWR_FILTER_TYPE_CUBIC, SWR_FILTER_TYPE_BLACKMAN_NUTTALL, SWR_FILTER_TYPE_KAISER }
 重新采样滤波器类型。 更多的...
 
#define SWR_FLAG_RESAMPLE    1
 即使采样率相同,也会强制重新采样。 更多的...
 

SwrContext 构造函数

struct SwrContext * swr_alloc(空)
 分配SwrContext。 更多的...
 
int swr_init (结构SwrContext * s )
 设置用户参数后初始化上下文。 更多的...
 
int swr_is_initialized (结构SwrContext * s )
 检查swr上下文是否已初始化。 更多的...
 
int swr_alloc_set_opts2(结构SwrContext **ps,const AVChannelLayout *out_ch_layout,枚举AVSampleFormat out_sample_fmt,int out_sample_rate,const AVChannelLayout *in_ch_layout,枚举AVSampleFormat in_sample_fmt,int in_sample_rate,int log_offset,void *log_ctx)
 如果需要,分配SwrContext并设置/重置公共参数。 更多的...
 

SwrContext 析构函数

void swr_free (结构SwrContext ** s )
 释放给定的SwrContext并将指针设置为 NULL。 更多的...
 
void swr_close (结构SwrContext * s )
 关闭上下文,以便swr_is_initialized()返回 0。 更多...
 

核心转换函数

int swr_convert(struct SwrContext * s,uint8_t ** out,int out_count,const uint8_t **in,int in_count)
 转换音频。 更多的...
 
int64_t swr_next_pts(结构SwrContext * s, int64_t pts)
 将下一个时间戳从输入时间戳转换为输出时间戳,单位为 1/(in_sample_rate * out_sample_rate)。 更多的...
 

低级选项设置功能

These functons provide a means to set low-level options that is not possible with the AVOption API.

int swr_set_compensation (struct SwrContext * s , intsample_delta , intcompensation_distance )
 激活重采样补偿(“软”补偿)。 更多的...
 
int swr_set_channel_mapping (struct SwrContext * s , const int * channel_map )
 设置自定义输入通道映射。 更多的...
 
int swr_build_matrix2(const AVChannelLayout * in_layout,const AVChannelLayout * out_layout,双center_mix_level,双surround_mix_level,双lfe_mix_level,双maxval,双rematrix_volume,双*矩阵,ptrdiff_t步幅,枚举AVMatrixEncoding矩阵编码,无效* log_context)
 生成通道混合矩阵。 更多的...
 
int swr_set_matrix(结构SwrContext * s, const double *矩阵,int 步幅)
 设置自定义混音矩阵。 更多的...
 

样品处理功能

int swr_drop_output (struct SwrContext * s , int count)
 删除指定数量的输出样本。 更多的...
 
int swr_inject_silence (struct SwrContext * s , int count)
 注入指定数量的静音样本。 更多的...
 
int64_t swr_get_delay (结构SwrContext * s , int64_t基)
 获取下一个输入样本相对于下一个输出样本将经历的延迟。 更多的...
 
int swr_get_out_samples(struct SwrContext * s,int in_samples)
 如果使用输入样本的 in_samples 进行调用,则找到下一个 swr_convert 调用将输出的样本数量的上限。 更多的...
 

配置访问器

unsigned swrsample_version(空)
 返回LIBSWRESAMPLE_VERSION_INT常量。 更多的...
 
const char * swrsample_configuration(空)
 返回 swr 构建时配置。 更多的...
 
const char * swrsample_license(无效)
 返回 swr 许可证。 更多的...
 

基于 AVFrame 的 API

int swr_convert_frame ( SwrContext *swr, AVFrame *输出, const AVFrame *输入)
 转换输入AVFrame中的样本并将其写入输出AVFrame。 更多的...
 
int swr_config_frame ( SwrContext *swr, const AVFrame * out , const AVFrame *in )
 使用 AVFrame 提供的信息 配置或重新配置SwrContext 。更多的...
 

详细说明

音频重采样、样本格式转换和混音库。

与 lswr 的交互是通过SwrContext完成的,它是用swr_alloc()或swr_alloc_set_opts2()分配的。它是不透明的,因此所有参数都必须使用AVOptions API设置。

为了使用 lswr,您需要做的第一件事是分配SwrContext。这可以通过swr_alloc()或swr_alloc_set_opts2()来完成。如果您使用前者,则必须通过AVOptions API 设置选项。后一个函数提供相同的功能,但它允许您在同一语句中设置一些常用选项。

例如,以下代码将设置从平面浮点采样格式到交错有符号 16 位整数的转换、从 48kHz 下采样到 44.1kHz 以及从 5.1 声道下混音到立体声(使用默认混合矩阵)。这是使用swr_alloc()函数。

av_opt_set_channel_layout(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0);
av_opt_set_channel_layout(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0);
av_opt_set_int(swr, "in_sample_rate", 48000, 0);
av_opt_set_int(swr, "out_sample_rate", 44100, 0);
av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);

也可以使用swr_alloc_set_opts2()完成相同的工作:

int ret = swr_alloc_set_opts2(&swr, // we're allocating a new context
AV_SAMPLE_FMT_S16, // out_sample_fmt
44100, // out_sample_rate
AV_SAMPLE_FMT_FLTP, // in_sample_fmt
48000, // in_sample_rate
0, // log_offset
NULL); // log_ctx

设置所有值后,必须使用swr_init()对其进行初始化。如果需要更改转换参数,可以使用AVOptions更改参数,如上面第一个示例中所述;或者使用swr_alloc_set_opts2(),但第一个参数是分配的上下文。然后您必须再次调用swr_init()。

转换本身是通过重复调用swr_convert()来完成的。请注意,如果您提供的输出空间不足或完成采样率转换(这需要“未来”样本),则样本可能会在 swr 中缓冲。不需要将来输入的样本可以使用swr_convert()随时检索(in_count 可以设置为 0)。在转换结束时,可以通过使用NULL in 和 0 in_count调用swr_convert()来刷新重采样缓冲区。

转换过程中使用的样本可以使用 libavutil样本操作API 进行管理,包括以下示例中使用的av_samples_alloc()函数。

输入和输出之间的延迟可以随时使用swr_get_delay()找到。

以下代码演示了假设上面的参数以及调用者定义的函数get_input()和 handle_output() 的转换循环:

uint8_t **input;
int in_samples;
while (get_input(&input, &in_samples)) {
uint8_t *output;
int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) +
in_samples, 44100, 48000, AV_ROUND_UP);
av_samples_alloc(&output, NULL, 2, out_samples,
out_samples = swr_convert(swr, &output, out_samples,
input, in_samples);
handle_output(output, out_samples);
}

转换完成后,必须使用swr_free()释放转换上下文以及与其关联的所有内容。swr_close ()函数也可用,但它的存在主要是为了与 libavresample 兼容,并且不需要调用。

如果在swr_free()之前数据没有完全刷新,则不会出现内存泄漏。

宏定义文档

◆ SWR_FLAG_RESAMPLE

#define SWR_FLAG_RESAMPLE   1

即使采样率相同,也会强制重新采样。

文件swresample.h第143行的定义。

枚举类型文档

◆ Swr抖动类型

抖动算法。

枚举器
SWR_DITHER_NONE 
SWR_DITHER_RECTANGULAR 
SWR_DITHER_TRIANGULAR 
SWR_DITHER_TRIANGULAR_HIGHPASS 
SWR_DITHER_NS 

不是 API/ABI 的一部分

SWR_DITHER_NS_LIPSHITZ 
SWR_DITHER_NS_F_WEIGHTED 
SWR_DITHER_NS_MODIFIED_E_WEIGHTED 
SWR_DITHER_NS_IMPROVED_E_WEIGHTED 
SWR_DITHER_NS_SHIBATA 
SWR_DITHER_NS_LOW_SHIBATA 
SWR_DITHER_NS_HIGH_SHIBATA 
SWR_DITHER_NB 

不是 API/ABI 的一部分

文件swresample.h第148行的定义。

◆ 软件引擎

enum SwrEngine

重新采样引擎。

枚举器
SWR_ENGINE_SWR 

SW重采样器。

SWR_ENGINE_SOXR 

SoX重采样器。

SWR_ENGINE_NB 

不是 API/ABI 的一部分

定义位于文件swresample.h的第166行。

◆ Swr滤波器类型

重新采样滤波器类型。

枚举器
SWR_FILTER_TYPE_CUBIC 

立方体。

SWR_FILTER_TYPE_BLACKMAN_NUTTALL 

布莱克曼·纳托尔(Blackman Nuttall)窗口化。

SWR_FILTER_TYPE_KAISER 

凯撒开窗以来。

文件swresample.h第173行的定义。

功能文档

◆ swr_get_class()

const AVClass* swr_get_class ( 空白  )

获取SwrContext的AVClass。

它可以与 AV_OPT_SEARCH_FAKE_OBJ 结合使用来检查选项。

See also
av_opt_find()。
Returns
SwrContext的AVClass _

文件options.c第164行的定义。

由opt_default()、resample_child_class_iterate()和show_help_default()引用。

◆ swr_alloc()

struct SwrContext* swr_alloc ( 空白  )

分配SwrContext。

如果使用此函数,则需要在调用swr_init()之前设置参数(手动或使用swr_alloc_set_opts2() ) 。

See also
swr_alloc_set_opts2()、swr_init()、swr_free()
Returns
错误时为 NULL,否则分配上下文

文件options.c第169行的定义。

由config_audio_output()、main()、open_audio()、opus_decode_init()、preinit()和swr_alloc_set_opts2()引用。

◆ swr_init()

int swr_init ( 结构SwrContext *  s)

设置用户参数后初始化上下文。

Note
必须使用AVOption API配置上下文。
See also
av_opt_set_int()
av_opt_set_dict()
Parameters
[in,out]s要初始化的 Swr 上下文
Returns
AVERROR 失败时的错误代码。

文件swresample.c第193行的定义。

由audio_decode_frame()、config_audio_output()、config_output()、config_props()、init_resampler()、main()、open_audio()、opus_init_resample()、swr_convert_frame()和swr_set_compensation()引用。

◆ swr_is_initialized()

int swr_is_initialized ( 结构SwrContext *  s)

检查swr上下文是否已初始化。

Parameters
[in]s要检查的 Swr 上下文
See also
swr_init()
Returns
已初始化则为正,未初始化则为0

文件swresample.c第832行的定义。

由opus_decode_frame()、opus_decode_subpacket()、swr_convert()和swr_convert_frame()引用。

◆ swr_alloc_set_opts2()

int swr_alloc_set_opts2 ( 结构SwrContext **  附:
常量AVChannelLayout *  输出通道布局,
枚举AVSampleFormat  输出样本fmt,
整数  输出样本率,
常量AVChannelLayout *  in_ch_layout ,
枚举AVSampleFormat  in_sample_fmt ,
整数  in_sample_rate ,
整数  对数偏移量,
空白 *  日志_ctx 
)

如果需要,分配SwrContext并设置/重置公共参数。

此函数不需要使用swr_alloc()分配 *ps 。另一方面,swr_alloc()可以使用swr_alloc_set_opts2()在分配的上下文上设置参数。

Parameters
ps指向现有 Swr 上下文(如果可用)的指针,如果不存在则指向 NULL。成功后,*ps 将被设置为分配的上下文。
out_ch_layout输出通道布局(例如AV_CHANNEL_LAYOUT_*)
out_sample_fmt输出样本格式(AV_SAMPLE_FMT_*)。
out_sample_rate输出采样率(频率,单位 Hz)
in_ch_layout输入通道布局(例如 AV_CHANNEL_LAYOUT_*)
in_sample_fmt输入样本格式(AV_SAMPLE_FMT_*)。
in_sample_rate输入采样率(频率,单位 Hz)
log_offset日志记录级别偏移
log_ctx父日志记录上下文,可以为 NULL
See also
swr_init()、swr_free()
Returns
成功时为 0,错误时为负 AVERROR 代码。出错时,Swr 上下文被释放,*ps 设置为 NULL。

定义位于文件swresample.c第85行。

由audio_decode_frame()、config_output()、config_props()、init_resampler()和main()引用。

◆ swr_free()

void swr_free ( 结构SwrContext **  s)

释放给定的SwrContext并将指针设置为 NULL。

Parameters
[in]s指向 Swr 上下文的指针

文件swresample.c第174行的定义。

由audio_decode_frame()、close_stream()、init_resampler()、main()、opus_decode_close()、stream_component_close()、swr_alloc_set_opts2()和uninit()引用。

◆ swr_close()

void swr_close ( 结构SwrContext *  s)

关闭上下文以便swr_is_initialized()返回 0。

可以通过运行swr_init()来恢复上下文,也可以在不使用swr_close()的情况下使用swr_init( ) 。提供此函数主要是为了简化尝试支持 libavresample 和 libswresample 的用例。

Parameters
[in,out]sswr 上下文要关闭

文件swresample.c第189行的定义。

由opus_decode_flush()、opus_decode_subpacket()、swr_config_frame()、swr_convert_frame()和swr_init()引用。

◆ swr_convert()

int swr_convert ( 结构SwrContext *  , _
uint8_t **  出去,
整数  输出计数,
常量 uint8_t **  在,
整数  计数中 
)

转换音频。

in 和 in_count 可以设置为 0 以在最后刷新最后几个样本。

如果提供的输入多于输出空间,则输入将被缓冲。您可以通过使用swr_get_out_samples()检索给定数量的输入样本所需的输出样本数量的上限来避免这种缓冲。只要有可能,转换将直接运行而不进行复制。

Parameters
s已分配 Swr 上下文,并设置了参数
out输出缓冲区,在打包音频的情况下只需要设置第一个
out_count每个通道样本中可用于输出的空间量
in输入缓冲区,在打包音频的情况下仅需要设置第一个缓冲区
in_count一个通道中可用的输入样本数量
Returns
每个通道输出的样本数,错误时为负值

文件swresample.c第836行的定义。

由audio_decode_frame()、convert_frame()、convert_samples()、filter_frame()、flush_frame()、main()、opus_decode_frame()、opus_flush_resample( ) 、opus_init_resample()、swr_convert()、swr_drop_output()、swr_inject_silence()引用,wrap()和write_audio_frame()。

◆ swr_next_pts()

int64_t swr_next_pts ( 结构SwrContext *  , _
int64_t  分 
)

将下一个时间戳从输入时间戳转换为输出时间戳,单位为 1/(in_sample_rate * out_sample_rate)。

Note
有 2 种略有不同的行为模式。
  • 当不使用自动时间戳补偿时,(min_compensation >= FLT_MAX) 在这种情况下,时间戳将通过并补偿延迟
  • 当使用自动时间戳补偿时,(min_compensation < FLT_MAX) 在这种情况下,输出时间戳将与输出样本数匹配。有关两种补偿模式,请参见 ffmpeg-resampler(1)。
Parameters
[in]s初始化的 Swr 上下文
[in]分下一个输入样本的时间戳,如果未知则为 INT64_MIN
See also
swr_set_compensation()、swr_drop_output()和swr_inject_silence()是内部用于时间戳补偿的函数。
Returns
下一个输出样本的输出时间戳

文件swresample.c第1041行的定义。

由filter_frame()和flush_frame()引用。

◆ swr_set_compensation()

int swr_set_compensation ( 结构SwrContext *  , _
整数  样本增量,
整数  补偿距离 
)

激活重采样补偿(“软”补偿)。

当需要时在swr_next_pts()中内部调用该函数。

Parameters
[in,out]s分配的 Swr 上下文。如果未初始化,或未设置 SWR_FLAG_RESAMPLE,则调用swr_init()并设置标志。
[in]样本增量每个样本的 PTS 增量
[in]补偿距离要补偿的样本数量
Returns
>= 0 成功,AVERROR 错误代码如果:
  • s一片空白,
  • compensation_distance小于 0,
  • compensation_distance是 0 但sample_delta 不是,
  • 重采样器不支持补偿,或者
  • swr_init()调用时失败。

文件swresample.c第1021行的定义。

由audio_decode_frame()和swr_next_pts()引用。

◆ swr_set_channel_mapping()

int swr_set_channel_mapping ( 结构SwrContext *  , _
常量整型*  频道地图 
)

设置自定义输入通道映射。

Parameters
[in,out]s已分配的 Swr 上下文,尚未初始化
[in]频道地图自定义输入通道映射(通道索引数组,-1 表示静音通道)
Returns
>= 0 表示成功,或 AVERROR 错误代码表示失败。

定义位于文件swresample.c的第32行。

由config_props()引用。

◆ swr_build_matrix2()

int swr_build_matrix2 ( 常量AVChannelLayout *  在布局中,
常量AVChannelLayout *  输出布局,
双倍的  center_mix_level ,
双倍的  环绕混合级别,
双倍的  lfe_mix_level ,
双倍的  最大值,
双倍的  重新矩阵体积,
双倍的*  矩阵,
ptrdiff_t  跨步,
枚举AVMatrixEncoding  矩阵编码,
空白 *  日志上下文 
)

生成通道混合矩阵。

该函数是 libswresample 内部使用的函数,用于构建默认的混合矩阵。它只是作为构建自定义矩阵的实用函数而公开的。

Parameters
布局中输入通道布局
输出布局输出通道布局
中心混合级别中央通道的混合电平
环绕混音级别环绕声道的混合级别
生命混合级别低频效果通道的混合电平
rematrix_maxval如果为 1.0,系数将被标准化以防止溢出。如果为 INT_MAX,则系数不会被归一化。
[out]矩阵混合系数;Matrix[i + stride * o] 是输入通道 i 在输出通道 o 中的权重。
跨步矩阵阵列中相邻输入通道之间的距离
矩阵编码矩阵立体声缩混模式(例如 dplii)
日志_ctx父日志记录上下文,可以为 NULL
Returns
成功时为 0,失败时为负 AVERROR 代码

文件rematrix.c第170行的定义。

由auto_matrix()引用。

◆ swr_set_matrix()

int swr_set_matrix ( 结构SwrContext *  , _
常量双*  矩阵,
整数  跨步 
)

设置自定义混音矩阵。

Parameters
s已分配的 Swr 上下文,尚未初始化
matrix混音系数;matrix[i + stride * o] 是输入通道 i 在输出通道 o 中的权重
stride矩阵行之间的偏移
Returns
>= 0 表示成功,或 AVERROR 错误代码表示失败。

文件rematrix.c第64行的定义。

由config_props()引用。

◆ swr_drop_output()

int swr_drop_output ( 结构SwrContext *  , _
整数  数数 
)

删除指定数量的输出样本。

如果需要“硬”补偿,则该函数与swr_inject_silence()一起由swr_next_pts()调用。

Parameters
s分配的 Swr 上下文
count要丢弃的样本数量
Returns
>= 0 表示成功,或负 AVERROR 代码表示失败

文件swresample.c第952行的定义。

由swr_next_pts()引用。

◆ swr_inject_silence()

int swr_inject_silence ( 结构SwrContext *  , _
整数  数数 
)

注入指定数量的静音样本。

如果需要“硬”补偿,则该函数与swr_drop_output()一起由swr_next_pts()调用。

Parameters
s分配的 Swr 上下文
count要丢弃的样本数量
Returns
>= 0 表示成功,或负 AVERROR 代码表示失败

文件swresample.c第963行的定义。

由swr_inject_silence()和swr_next_pts()引用。

◆ swr_get_delay()

int64_t swr_get_delay ( 结构SwrContext *  , _
int64_t  根据 
)

获取下一个输入样本相对于下一个输出样本将经历的延迟。

如果提供的输入多于可用输出空间,Swresample 可以缓冲数据,并且采样率之间的转换也需要延迟。该函数返回所有此类延迟的总和。确切的延迟不一定是输入或输出采样率的整数值。特别是当按较大值进行下采样时,输出采样率可能不是表示延迟的糟糕选择,与上采样和输入采样率类似。

Parameters
sswr上下文
base时基,其中返回的延迟将为:
  • 如果设置为 1,则返回的延迟以秒为单位
  • 如果设置为 1000,则返回的延迟以毫秒为单位
  • 如果它设置为输入采样率,则返回的延迟位于输入样本中
  • 如果它设置为输出采样率,则返回的延迟位于输出样本中
  • 如果它是 in_sample_rate 和 out_sample_rate 的最小公倍数,则将返回精确的无舍入延迟
Returns
延迟时间为 1/base单位。

文件swresample.c第991行的定义。

由filter_frame()、main()、swr_convert_frame()、swr_next_pts()和write_audio_frame()引用。

◆ swr_get_out_samples()

int swr_get_out_samples ( 结构SwrContext *  , _
整数  样本中 
)

如果使用输入样本的 in_samples 进行调用,则找到下一个 swr_convert 调用将输出的样本数量的上限。

这取决于内部状态,任何改变内部状态的行为(比如进一步的swr_convert()调用)都可能会改变swr_get_out_samples()对于相同数量的输入样本返回的样本数量。

Parameters
in_samples输入样本的数量。
Note
任何对swr_inject_silence()、swr_convert()、swr_next_pts()或swr_set_compensation() 的调用都会使此限制无效
建议将正确的可用缓冲区大小传递给swr_convert()等所有函数,即使swr_get_out_samples()指示将使用更少的缓冲区大小。
Returns
下一个 swr_convert 将输出的样本数量的上限或表示错误的负值

文件swresample.c第999行的定义。

由swr_convert()引用。

◆ swrsample_version()

unsigned swresample_version ( 空白  )

返回LIBSWRESAMPLE_VERSION_INT常量。

这对于检查构建时 libswresample 是否与运行时版本相同很有用。

Returns
unsigned int 类型版本

定义位于文件version.c的第 29行。

◆ swrsample_configuration()

const char* swresample_configuration ( 空白  )

返回 swr 构建时配置。

Returns
构建时./configure 标志

定义位于文件version.c的第35行。

◆ swrsample_license()

const char* swresample_license ( 空白  )

返回 swr 许可证。

Returns
libsresample 的许可证,在构建时确定

定义位于文件version.c的第 40行。

◆ swr_convert_frame()

int swr_convert_frame ( Swr上下文*  驻波比,
AV 帧*  输出,
常量AVFrame *  输入 
)

转换输入AVFrame中的样本并将其写入输出AVFrame。

输入和输出 AVFrame 必须设置 channel_layout、sample_rate 和 format。

如果输出AVFrame没有分配数据指针,则将调用av_frame_get_buffer()来设置 nb_samples 字段以分配帧。

输出AVFrame可以为 NULL 或分配的样本少于所需的样本。在这种情况下,任何未写入输出的剩余样本都将添加到内部 FIFO 缓冲区,以便在下次调用此函数或 swr_convert( )时返回。

如果转换采样率,内部重采样延迟缓冲区中可能会残留数据。swr_get_delay()告诉剩余样本的数量。要获取此数据作为输出,请使用 NULL 输入调用此函数或swr_convert() 。

如果SwrContext配置与输出和输入AVFrame设置不匹配,则不会进行转换,并且根据哪个AVFrame不匹配 AVERROR_OUTPUT_CHANGED、AVERROR_INPUT_CHANGED 或返回它们的按位或的结果。

See also
swr_delay()
swr_convert()
swr_get_delay()
Parameters
swr音频重采样上下文
output输出AV帧
input输入AV帧
Returns
成功时为 0,失败或配置不匹配时为 AVERROR。

文件swresample_frame.c第184行的定义。

◆ swr_config_frame()

int swr_config_frame ( Swr上下文*  驻波比,
常量AVFrame *  出去,
常量AVFrame *  在 
)

使用 AVFrame 提供的信息配置或重新配置SwrContext 。

即使失败,原始重采样上下文也会重置。如果上下文打开,该函数会在内部调用swr_close() 。

See also
swr_close() ;
Parameters
swr音频重采样上下文
out输出AV帧
in输入AV帧
Returns
成功时为 0,失败时为 AVERROR。

定义位于文件swresample_frame.c第27行。

由swr_convert_frame()引用。

AV_SAMPLE_FMT_FLTP
@AV_SAMPLE_FMT_FLTP
浮动、平面
定义: samplefmt.h:66
AV_CHANNEL_LAYOUT_STEREO
#定义 AV_CHANNEL_LAYOUT_STEREO
定义: channel_layout.h:385
输出
filter_frame 对于不使用该方法的过滤器,当将帧推送到过滤器的输入时调用此方法。除了以可重入方式之外,可以随时调用该方法,如果输入帧足以产生输出
Definition: filter_design.txt:225
get_input
static int get_input(AVFrame *frame, int frame_num)
Definition: filter_audio.c:239
av_samples_alloc
int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Allocate a samples buffer for nb_samples samples, and fill data pointers and linesize accordingly.
Definition: samplefmt.c:182
AV_ROUND_UP
@ AV_ROUND_UP
Round toward +infinity.
Definition: mathematics.h:134
av_opt_set_channel_layout
FF_DISABLE_DEPRECATION_WARNINGS int av_opt_set_channel_layout(void *obj, const char *name, int64_t cl, int search_flags)
Definition: opt.c:749
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:211
swr_get_delay
int64_t swr_get_delay(struct SwrContext *s, int64_t base)
Gets the delay the next input sample will experience relative to the next output sample.
Definition: swresample.c:991
swr_alloc
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
Definition: options.c:169
SwrContext
The libswresample context.
Definition: swresample_internal.h:95
NULL
#define NULL
Definition: coverity.c:32
AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_5POINT1
Definition: channel_layout.h:221
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:624
av_rescale_rnd
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:58
swr_alloc_set_opts2
int swr_alloc_set_opts2(struct SwrContext **ps, const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, const AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)
Allocate SwrContext if needed and set/reset common parameters.
Definition: swresample.c:85
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:309
swr_convert
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t **out_arg, int out_count, const uint8_t **in_arg, int in_count)
Convert audio.
Definition: swresample.c:836
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
ret
ret
Definition: filter_design.txt:187
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AV_CHANNEL_LAYOUT_5POINT1
#define AV_CHANNEL_LAYOUT_5POINT1
Definition: channel_layout.h:395
av_opt_set_sample_fmt
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)
Definition: opt.c:742