swr_convert 转换解码数据

swr_convert

由于ffmpeg最新版本(从2.1开始貌似)使用avcodec_decode_audio4函数来解码音频,但解码得到的数据类型为float4bit,而播放器播放的格式一般为S16(signed16bit),就需要对解码得到的数据进行转换,然而,ffmpeg已经帮我们做好了,只需调用API就可以了,这个函数就是:swr_convert


原型:int swr_convert(struct SwrContext * s,  uint8_t ** out,  int out_count,  const uint8_t ** in, int in_count )

Convertaudio.

in and in_count can be set to 0 to flush the last few samples out at the end.

If more input is provided than output space then the input will be buffered. You can avoid this buffering by providing more output space than input. 

Convertion will run directly without copying whenever possible.

Parameters

 

s

allocated Swr context, with parameters set

out

output buffers, only the first one need be set in case of packed audio

out_count

amount of space available for output in samples per channel

in

input buffers, only the first one need to be set in case of packed audio

in_count

number of input samples available in one channel

Returns

number of samples output per channel, negativevalue on error

用时注意,第一个参数初始化后还需要将解码环境中的一部分参数赋给它。

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值