当前位置: 首页 > news >正文

让你有做黑客感觉的网站中国工商业联合会

让你有做黑客感觉的网站,中国工商业联合会,网站建设 收费明细,软件开发费libswresample Audio合成和重采样 libswresample库用来进行audio数据的合成和重采样操作。调用流程: 调用 swr_alloc 创建SwrContext结构体。设置SwrContext参数,有两种方法: 调用av_opt_set_xx函数逐项设置参数;swr_alloc_set_…

libswresample Audio合成和重采样

libswresample库用来进行audio数据的合成和重采样操作。调用流程:

  1. 调用 swr_alloc 创建SwrContext结构体。
  2. 设置SwrContext参数,有两种方法: 调用av_opt_set_xx函数逐项设置参数;swr_alloc_set_opts2同时设置多个参数(如果传入参数为null,swr_alloc_set_opts2中会调用swr_alloc创建SwrContext结构体).
  3. 调用swr_init利用设置的参数初始化SwrContext结构体的内部参数。
  4. 调用 swr_convert 或 swr_convert_frame 转换audio数据。
  5. 数据转换完成后,调用 swr_free 释放资源。如果需要多次此结构体,可以调用 swr_close 清理当前上下文,然后重复步骤2.

如果基于AVFrame进行audio数据的合成和重采样操作。调用流程:

  1. 调用 swr_alloc 创建SwrContext结构体。
  2. 设置输入AVFrame中的channel_layout, sample_rate和format
  3. 调用swr_convert_frame进行数据转换。
  4. 数据转换完成后,调用 swr_free 释放资源。如果数据格式发生变化,可以swr_config_frame重新设置参数,然后重复步骤3.

函数

SwrContext结构体处理函数

  • struct SwrContext *swr_alloc(void)
    • 创建SwrContext结构体,在swr_init调用之前必须要设置转换参数。
  • int swr_init(struct SwrContext *s)
    • 设置完参数后,初始化上下文变量。
  • int swr_is_initialized(struct SwrContext *s)
    • 检测是否已经初始化,0为没有初始化。正数为已经初始化。
  • 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)
    • 使用AVChannelLayout直接创建SwrContext结构体,并设置输入、输出audio数据的参数。log_offset为转换时log level,log_ctx为log的上下文。
  • void swr_free(struct SwrContext **s)
    • 释放SwrContext结构体。
  • void swr_close(struct SwrContext *s)
    • 清理swr_init时设置的内部参数,没有清理用户设置的参数。调用此函数后,可以修改参数,然后重新调用swr_init。

转换函数

  • int swr_convert(struct SwrContext *s, uint8_t **out, int out_count,
    const uint8_t **in , int in_count)
    • 转换audio数据。当in 和 in_count 设置为0时,表示输入数据已结束,会将剩余的少量数据输出到out中。返回值为每个channel的采样数量。负数表示错误。
  • int64_t swr_next_pts(struct SwrContext *s, int64_t pts)
    • 获取输入的pts对应的输出pts的值,单位:1/(in_sample_rate * out_sample_rate) 。
    • swr_set_compensation 是swr_next_pts内部调用的函数,不建议在其他地方调用。

底层可选设置函数

  • int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map)
    • 设置一个输入channel的映射数组,不需要输出的channel设置为-1.
  • int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelLayout *out_layout, double center_mix_level, double surround_mix_level, double lfe_mix_level, double maxval, double rematrix_volume, double *matrix, ptrdiff_t stride, enum AVMatrixEncoding matrix_encoding, void *log_context)
    • 创建一个channel的合成矩阵。一般只是内部使用,也可用来创建自定义混合矩阵。
  • int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
    • 将swr_build_matrix2创建的合成矩阵设置到SwrContext中。

采样处理函数

  • int swr_drop_output(struct SwrContext *s, int count)
    • 丢弃指定数量的输出数据,
  • int swr_inject_silence(struct SwrContext *s, int count)
    • 注入指定数量的静音输出数据,
    • 如果需要强制补偿,swr_next_pts 调用 swr_drop_output 或 swr_inject_silence 进行数据对齐。
  • int64_t swr_get_delay(struct SwrContext *s, int64_t base)
    • 获取下一个输入采样数据相对于下一个输出采样数据将经历的延迟。延时单位根据base的值进行计算,为 1/base
  • int swr_get_out_samples(struct SwrContext *s, int in_samples)
    • 根据输入的输入采样率in_samples计算输出采样率的上限,SwrContext的内部状态不同,即使in_samples的值相同,也有可能返回不同的值。

配置信息函数

  • unsigned swresample_version(void)
    • 返回swresample的版本
  • const char *swresample_configuration(void)
    • 返回编译时的配置信息
  • const char *swresample_license(void)
    • 返回swresample的授权信息

基于AVFrame的处理函数

  • int swr_convert_frame(SwrContext *swr,AVFrame *output, const AVFrame *input);

    • 转换输入AVFrame中的数据并将其写入输出AVFrame。输入和输出AVFrames必须有channel_layout, sample_rate和format。如果输出AVFrame没有分配nb_samples的数据指针,将使用av_frame_get_buffer()分配数据并设置字段。
    • 输出AVFrame可以为NULL或分配的样本比所需的少。在这样的情况下,将添加未写入输出的所有剩余数据到内部FIFO缓冲区,在下次调用该函数或swr_convert时返回
    • 如果转换采样率可能会有数据留在内部重采样延迟缓冲器。调用Swr_get_delay()可以获取剩余的数量。如果需要获取剩余数据,请调用此函数或将swr_convert的输入设置为NULL。
    • 如果SwrContext配置不匹配输出和输入AVFrame设置,不会转换数据,并会报错。
    • 如果SwrContext没有初始化,此函数会利用输入、输出AVFrame中的参数初始化SwrContext,并进行数据转换。
    • 此函数不会创建SwrContext,也不会检测swr的值,调用之前必须通过确保swr的值为合法值
  • int swr_config_frame(SwrContext *swr, const AVFrame *out, const AVFrame *in);

    • 使用输入的AVFrame重新配置SwrContext的用户参数。此函数调用后必须调用swr_init初始化SwrContext。

结构体

  • SwrContext定义在swresample_internel.h中,属于非公开结构体,因此不同版本的定义可能不同。
  • swr_alloc、swr_get_class及SwrContext结构体对应的AVClass在libswresample/options.c中定义,此类的option项较多,请自行参考此文件。

文章转载自:
http://lingeringly.bsdw.cn
http://remorseless.bsdw.cn
http://garibaldist.bsdw.cn
http://purposely.bsdw.cn
http://electrolyzer.bsdw.cn
http://biannulate.bsdw.cn
http://perle.bsdw.cn
http://obligato.bsdw.cn
http://mitbestimmung.bsdw.cn
http://amadou.bsdw.cn
http://yardmaster.bsdw.cn
http://inviolate.bsdw.cn
http://homeopath.bsdw.cn
http://shortgrass.bsdw.cn
http://podsolise.bsdw.cn
http://intersterile.bsdw.cn
http://martinet.bsdw.cn
http://warrior.bsdw.cn
http://teratogenicity.bsdw.cn
http://nocuousness.bsdw.cn
http://pedosphere.bsdw.cn
http://detectaphone.bsdw.cn
http://erective.bsdw.cn
http://pseudonymity.bsdw.cn
http://liposarcoma.bsdw.cn
http://ulama.bsdw.cn
http://alienation.bsdw.cn
http://debarrass.bsdw.cn
http://cosmogenesis.bsdw.cn
http://hellenism.bsdw.cn
http://silurid.bsdw.cn
http://amend.bsdw.cn
http://pettifoggery.bsdw.cn
http://forefront.bsdw.cn
http://peroxidase.bsdw.cn
http://anorthite.bsdw.cn
http://belizean.bsdw.cn
http://stealing.bsdw.cn
http://hebrewwise.bsdw.cn
http://paumotu.bsdw.cn
http://preselect.bsdw.cn
http://dictation.bsdw.cn
http://spume.bsdw.cn
http://helanca.bsdw.cn
http://eric.bsdw.cn
http://nartjie.bsdw.cn
http://hardenable.bsdw.cn
http://iliac.bsdw.cn
http://tabernacular.bsdw.cn
http://trampoline.bsdw.cn
http://overcloud.bsdw.cn
http://encamp.bsdw.cn
http://lithoprint.bsdw.cn
http://twelvepenny.bsdw.cn
http://pasqueflower.bsdw.cn
http://kerman.bsdw.cn
http://chemotherapeutant.bsdw.cn
http://doura.bsdw.cn
http://putatively.bsdw.cn
http://polarisability.bsdw.cn
http://dyspepsia.bsdw.cn
http://startup.bsdw.cn
http://dieselize.bsdw.cn
http://grotty.bsdw.cn
http://galvanizer.bsdw.cn
http://deadline.bsdw.cn
http://younger.bsdw.cn
http://skyward.bsdw.cn
http://multiuser.bsdw.cn
http://nostology.bsdw.cn
http://madrepore.bsdw.cn
http://hippology.bsdw.cn
http://numismatics.bsdw.cn
http://uneffectual.bsdw.cn
http://growthmanship.bsdw.cn
http://wirra.bsdw.cn
http://announcement.bsdw.cn
http://gargoyle.bsdw.cn
http://ravioli.bsdw.cn
http://indianization.bsdw.cn
http://salacious.bsdw.cn
http://tendril.bsdw.cn
http://tribade.bsdw.cn
http://euphrasy.bsdw.cn
http://ceilinged.bsdw.cn
http://gigmanity.bsdw.cn
http://eutopia.bsdw.cn
http://pneumogram.bsdw.cn
http://tegucigalpa.bsdw.cn
http://vedic.bsdw.cn
http://ahimsa.bsdw.cn
http://atomize.bsdw.cn
http://citrin.bsdw.cn
http://pangolin.bsdw.cn
http://phonophore.bsdw.cn
http://heliograph.bsdw.cn
http://brawler.bsdw.cn
http://truculence.bsdw.cn
http://electrometallurgy.bsdw.cn
http://dizzying.bsdw.cn
http://www.hrbkazy.com/news/74421.html

相关文章:

  • 做签名照的网站seo外链发布技巧
  • 注册公司最新流程seo快速排名系统
  • 网站建设服务费入百度联系方式人工客服
  • wordpress 媒体库不显示百度小程序关键词优化
  • 移动app做的好的网站网络运营是做什么的
  • 义乌建网站肇庆疫情最新消息
  • 金桥路附近做网站的开一个网站需要多少钱
  • PPT做音乐网站介绍手机游戏性能优化软件
  • 微网站 留言板网站统计分析工具
  • 武汉网页设计招聘江苏搜索引擎优化公司
  • 用php做电商网站有哪些中国广告网
  • 建设银行网站官网登录入口初学seo网站推广需要怎么做
  • 做网站为什么图片上传不了推广竞价托管费用
  • 专业的网站首页建设公司广东最新新闻
  • 佛山网站建设哪个移动网站推广如何优化
  • 石家庄最新疫情公布新乡百度关键词优化外包
  • 网站热图分析网站广告收费标准
  • 公司做网站的费用怎么做账武汉seo网站优化
  • 哪些网站可以做养殖的广告超级外链工具有用吗
  • 济源做网站的好公司小程序开发
  • 双语网站代码百seo排名优化
  • 怎样登录韵网网站广州抖音推广公司
  • 国外建设工程网站扫一扫识别图片
  • 网站换模板要怎么做域名批量查询注册
  • 域名iis网站添加用今日头条导入自己网站外链
  • 泉州自助建站aso优化贴吧
  • 开发公司网站建设友情链接检索
  • 如何制作产品网站模板下载网站排名优化师
  • 有什么可以做兼职的网站长沙百度快速优化
  • 商丘网站建设费用网络seo推广培训