bytestream_put_buffer(&p, "OpusHead", 8);
bytestream_put_byte(&p, 1); /* Version */
bytestream_put_byte(&p, channels);
bytestream_put_le16(&p, avctx->initial_padding); /* Lookahead samples at 48kHz */
bytestream_put_le32(&p, avctx->sample_rate); /* Original sample rate */
Data Fields
1 int OpusHead::version 1个字节
The Ogg Opus format version, in the range 0...255.
The top 4 bits represent a "major" version, and the bottom four bits represent
backwards-compatible "minor" revisions. The current specification describes version
1. This library will recognize versions up through 15 as backwards compatible with
the current specification. An earlier draft of the specification described a version 0, but
the only difference between version 1 and version 0 is that version 0 did not specify the
semantics for handling the version field.

2 int OpusHead::channel_count
The number of channels, in the range 1...255.
3 unsigned OpusHead::pre_skip =2字节
The number of samples that should be discarded丢弃 from the beginning of the stream.
4 opus uint32 OpusHead::input_sample_rate
The sampling rate of the original input.
All Opus audio is coded at 48 kHz, and should also be decoded at 48 kHz for playback
(unless the target hardware does not support this sampling rate). However, this field
may be used to resample the audio back to the original sampling rate, for example,
when saving the output to a file.
5 int OpusHead::output_gain
The gain to apply to the decoded output, in dB, as a Q8 value in the range.
-32768...32767. The decoder will automatically scale the output by pow(10,output_-
gain/(20.0256)).
6 int OpusHead::mapping_family
The channel mapping family, in the range 0...255.
Channel mapping family 0 covers mono or stereo in a single stream. Channel mapping
family 1 covers 1 to 8 channels in one or more streams, using the Vorbis speaker
assignments. Channel mapping family 255 covers 1 to 255 channels in one or more
streams, but without any defined speaker assignment.
7 int OpusHead::stream_count
The number of Opus streams in each Ogg packet, in the range 1...255.
8 int OpusHead::coupled_count
The number of coupled Opus streams in each Ogg packet, in the range 0...127.
This must satisfy 0 <= coupled_count <= stream_count and coupled-
_count + stream_count <= 255. The coupled streams appear first, before
all uncoupled streams, in an Ogg Opus packet.
9 unsigned char OpusHead::mapping[OPUS_CHANNEL_COUNT_MAX]
The mapping from coded stream channels to output channels.
Let index=mapping[k] be the value for channel k. If index<2coupled_-
count, then it refers to the left channel from stream (index/2) if even, and the
right channel from stream (index/2) if odd. Otherwise, it refers to the output of the
uncoupled stream (index-coupled_count).
opus_head_parse
ffmpeg的extradata
#define OPUS_HEAD_SIZE 19
Total:      19 ( 0x00000013 )
4F, 70, 75, 73, 48, 65, 61, 64,  01=version, 01=channels, (68, 00), 80, 3E, 00, 00, 
(00, 00), 00,    //OpusHead..h..>.....
bytestream_put_le16
解析通道数和采样率
int ch = audioCtx->extradata[9];
 uint32_t hz=*(uint32_t*)&(audioCtx->extradata[12]);
aac 参数包大小4+11+2+2=19
opus=4+11+2+19=36
解析:
avc->channels = avc->extradata_size >= 10 ? avc->extradata[9] : (avc->channels == 1) ? 1 : 2;
参考:
opusfile_api-0.2(opus 规范).pdf

opus 规范 与参数解析的更多相关文章

  1. argparse - 命令行选项与参数解析(转)

    argparse - 命令行选项与参数解析(译)Mar 30, 2013 原文:argparse – Command line option and argument parsing 译者:young ...

  2. argparse - 命令行选项与参数解析

    argparse模块作为optparse的一个替代被添加到Python2.7.argparse的实现支持一些不易于添加到optparse以及要求向后不兼容API变化的特性,因此以一个新模块添加到标准库 ...

  3. Python学习笔记之参数解析

    python提供了两种方法进行命令行的参数解析,分别是getopt和optparse类中的模块OptionParser,下面分别详细了解这两个模块: 1.getopt模块 首先复习C语言的命令行解析: ...

  4. SpringMVC源码阅读:Controller中参数解析

    1.前言 SpringMVC是目前J2EE平台的主流Web框架,不熟悉的园友可以看SpringMVC源码阅读入门,它交代了SpringMVC的基础知识和源码阅读的技巧 本文将通过源码(基于Spring ...

  5. Python内置的一个用于命令项选项与参数解析的模块argparse

    一.argparse简单使用 我们先来看一个简单示例.主要有三个步骤: 创建 ArgumentParser() 对象 调用 add_argument() 方法添加参数 使用 parse_args() ...

  6. 写个C#命令行参数解析的小工具

    最近测试工作做的比较多因此时常要创建一些控制台类型的应用程序.因为程序有不同的参数开关,需要在程序启动的时候通过命令行来给程序传递各种开关和参数.直接操作args有些不方便,所以就写了个解析参数的小工 ...

  7. Python--命令行参数解析Demo

    写没有操作界面的程序时,最讨厌的就是参数解析问题,尤其是很多参数那种,下面是一个小Demo,拿出来与各位分享: # -*- coding:utf8 -*- import os import datet ...

  8. Node基础:url查询参数解析之querystring

    模块概述 在nodejs中,提供了querystring这个模块,用来做url查询参数的解析,使用非常简单. 模块总共有四个方法,绝大部分时,我们只会用到 .parse(). .stringify() ...

  9. Zookeeper + Hadoop2.6 集群HA + spark1.6完整搭建与所有参数解析

    废话就不多说了,直接开始啦~ 安装环境变量: 使用linx下的解压软件,解压找到里面的install 或者 ls 运行这个进行安装 yum install gcc yum install gcc-c+ ...

随机推荐

  1. 不仅仅是浏览器 走近Chrome开发人员工具

    Chrome浏览器以其简单.快速.安全.稳定.扩展丰富等特性受到了不少人的喜爱,除了这些特性,Chrome浏览器还提供了非常简单方便的开发人员工具,可以为开发提高效率,加上Chrome浏览器对HTML ...

  2. High Speed Inter-CHIP USB 2.0 PHY

    转载:http://arasan.com/products/usb/usb-2-0/hsic-phy/ High Speed Inter-CHIP USB 2.0 PHY USB is the ubi ...

  3. javascript模块化有什么意义?

    以前,所有的javascript都写在一个文件里,方便只加载一个文件就可以了,但是代码越来越多,必须分成多个文件加载,类似: <script src="1.js">&l ...

  4. pdf.js 添加自定义loading动画

    最近做了个手机端pdf预览的功能,用到pdf.js这个库,效果还不错.但是在网络差.文件大时,页面一直空白,体验不是很好. 于是加了个loading动画. <div id="loadi ...

  5. Go测试,功能测试,性能测试,测试辅助,go test 工具,高级测试,IO相关测试,黑盒测试,HTTP测试,进程测试

    go命令教程: http://wiki.jikexueyuan.com/project/go-command-tutorial/0.5.html Go测试 第一个测试 “Hello Test!” 首先 ...

  6. C#断点续传

    我们经常使用下载工具,如bit精灵.迅雷.FlashGet,这些软件都支持断点续传. 断点续传即下载任务暂停后可以继续,而无需重新下载,即下载时需要通知服务器的起始位置.如果允许多线程进行分片下载,必 ...

  7. 深度剖析OpenGL ES中的多线程和多窗口渲染技术

    由 创新网小编 于 星期五, 2014-04-11 14:56 发表 移动设备中的CPU和GPU已经变得很强大,到处都是配备一个或多个高分辨率屏幕的设备,需要使用带有图形驱动器的复杂交互也日益增加.在 ...

  8. char p[]与char *p的区别

    #include <iostream> using namespace std; int main(void) { char *pp = "abc";//*pp指向的是 ...

  9. HDU2491 Priest John&#39;s Busiest Day

    题目链接 题意: 有n个人要进行乒乓球比赛,每一个人都一个能力值.每一个人出现的次序就是他们住的位置 如今要求进行一场比赛,三个人,裁判的能力值在两个选手之间,住的位置也在两个人的之间 问这样的比赛一 ...

  10. 被动信息收集1——DNS基础 + DNS解析工具 NSLOOKUP使用

    被动信息收集 特点: 基于公开渠道 与目标不直接接触 避免留下一切痕迹 标准參考--OSINT: 美国军方 北大西洋公约组织 名词解释 DNS--Domain Name System 域名系统 因特网 ...