首页 > 其他分享 >AMR和AMR-WB协议数据格式

AMR和AMR-WB协议数据格式

时间:2022-10-25 08:23:18浏览次数:77  
标签:00 WB Header https 数据格式 AMR Payload

1. 概述

查看https://www.rfc-editor.org/rfc/rfc3267.txt,可了解到该协议在第4章节定义了RTP上AMR和AMR-WB的两种数据格式Bandwidth-Efficient Mode和Octet-aligned Mode,第5章节定义了文件存储AMR和AMR-WB的数据格式。

   1. Introduction.................................................... 3
   2. Conventions and Acronyms........................................ 3
   3. Background on AMR/AMR-WB and Design Principles.................. 4
     3.1. The Adaptive Multi-Rate (AMR) Speech Codec.................. 4
     3.2. The Adaptive Multi-Rate Wideband (AMR-WB) Speech Codec...... 5
     3.3. Multi-rate Encoding and Mode Adaptation..................... 5
     3.4. Voice Activity Detection and Discontinuous Transmission..... 6
     3.5. Support for Multi-Channel Session........................... 6
     3.6. Unequal Bit-error Detection and Protection.................. 7
       3.6.1. Applying UEP and UED in an IP Network................... 7
     3.7. Robustness against Packet Loss.............................. 9
       3.7.1. Use of Forward Error Correction (FEC)................... 9
       3.7.2. Use of Frame Interleaving...............................11
     3.8. Bandwidth Efficient or Octet-aligned Mode...................11
     3.9. AMR or AMR-WB Speech over IP scenarios......................12
   4. AMR and AMR-WB RTP Payload Formats..............................14
     4.1. RTP Header Usage............................................14
     4.2. Payload Structure...........................................16
     4.3. Bandwidth-Efficient Mode....................................16
       4.3.1. The Payload Header......................................16
       4.3.2. The Payload Table of Contents...........................17
       4.3.3. Speech Data.............................................19
       4.3.4. Algorithm for Forming the Payload.......................20
       4.3.5 Payload Examples.........................................21
            4.3.5.1. Single Channel Payload Carrying a Single Frame...21
            4.3.5.2. Single Channel Payload Carrying Multiple Frames..22
            4.3.5.3. Multi-Channel Payload Carrying Multiple Frames...23
     4.4. Octet-aligned Mode..........................................25
       4.4.1. The Payload Header......................................25
       4.4.2. The Payload Table of Contents and Frame CRCs............26
         4.4.2.1. Use of Frame CRC for UED over IP....................28
       4.4.3. Speech Data.............................................30
       4.4.4. Methods for Forming the Payload.........................30
       4.4.5. Payload Examples........................................32
            4.4.5.1. Basic Single Channel Payload Carrying
                     Multiple Frames..................................32
         4.4.5.2. Two Channel Payload with CRC, Interleaving,
                     and Robust-sorting...............................32
     4.5. Implementation Considerations...............................33
   5. AMR and AMR-WB Storage Format...................................34
     5.1. Single Channel Header.......................................34
     5.2. Multi-channel Header........................................35
     5.3. Speech Frames...............................................36
   6. Congestion Control..............................................37
   7. Security Considerations.........................................37
     7.1. Confidentiality.............................................37
     7.2. Authentication..............................................38
     7.3. Decoding Validation.........................................38
   8. Payload Format Parameters.......................................38
     8.1. AMR MIME Registration.......................................39
     8.2. AMR-WB MIME Registration....................................41
     8.3. Mapping MIME Parameters into SDP............................44
   9. IANA Considerations.............................................45
   10. Acknowledgements...............................................45
   11. References.....................................................45
     11.1 Informative References......................................46
   12. Authors' Addresses.............................................48
   13. Full Copyright Statement.......................................49

2. AMR文件解析

2.1. 选择文件

选择文件如下:
/frameworks/base/media/tests/contents/media_api/music/test_amr_ietf.amr

2.2. 分析文件

23 21 41 4D 52 0A      -> #!AMR\n                     RFC3267 5.1. Single channel Header
3C 91 17 16 BE 66 79 E1 E0 01 E7 AF F0 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3C 48 77 24 96 66 79 E1 E0 01 E7 BA F0 00 00 00 C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3C 55 00 88 B6 66 79 E1 E0 01 E7 CF F0 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3C 48 F9 1F 96 66 79 E1 E0 01 E7 8A F0 00 00 00 C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3C 54 FD 1F B6 66 79 E1 E0 01 E7 CF F0 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
3C                     -> FT = b0111 = 7(12.2kbit/s)  3GPP26.101 4.1	AMR Header and AMR Auxiliary Information
    0 1 2 3 4 5 6 7    -> Q = 1(Good frame)           3GPP26.101 4.1	AMR Header and AMR Auxiliary Information
   +-+-+-+-+-+-+-+-+
   |P|  FT   |Q|P|P|
   +-+-+-+-+-+-+-+-+
    0 0 1 1 1 1 0 0
                       -> mode = b0111 = 7            size = packed_size[7] + 1 = 32
https://github.com/marcelogp/AMR-WB/blob/master/libavformat/amr.c
static const uint8_t packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};

3GPP26.101 4.2.2	AMR Core Frame with speech bits: Class division
Class A 81 bits
Class B 103 bits
Class C 60 bits

3. AMR-WB文件解析

3.1 文件解析

23 21 41 4D 52 2D 57 42 0A  -> #!AMR-WB\n                     RFC3267 5.1. Single channel Header
44 54 06 22 40 CB 82 8C 42 69 20 09 1D 83 CC CE E6 E7 FE 14 D8 43 E7 E0 C1 47 A4 E0 4D 20 50 DB 42 E2 1D 86 80 D1 00 36 B3 3E 53 1A B0 45 71 FB 0D 8C E9 E9 1E 26 EB 9A A7 75 11 86 F0 
44 40 2A 66 96 F9 A4 DC C6 1F A9 E0 81 CF 4A 14 81 BF FC 86 A8 BB 72 D8 45 8E 3E 2B 1D B6 F1 F9 AD 4C 45 20 A7 A8 CA 14 62 1A 4F 35 D2 7C 16 A9 6A B3 77 B9 0E 16 DC 87 11 F9 D5 C2 E8 

44                     -> FT = b1000 = 8(AMR-WB 23.85 kbit/s)  3GPP26.201 4.1	AMR-WB Header and AMR-WB Auxiliary Information
    0 1 2 3 4 5 6 7    -> Q = 1(Good frame)                    3GPP26.201 4.1	AMR-WB Header and AMR-WB Auxiliary Information
   +-+-+-+-+-+-+-+-+
   |P|  FT   |Q|P|P|
   +-+-+-+-+-+-+-+-+
    0 1 0 0 0 1 0 0
                       -> mode = b1000 = 8            size = packed_size[8] + 1 = 62
https://github.com/marcelogp/AMR-WB/blob/master/libavformat/amr.c
static uint8_t packed_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};

3.2 数据流解析

从wireshark查看一个Bandwidth-Efficient Mode的AMR-WB数据流进行解析。

f470431cbbc3dcfcc92d21de35f03d375a7bf5b970b67f0ccfb2c08dc27889c40d5bc7343700f74bb08903a03bf49f4763bf2ced87457faf1b43580e0c

参考RFC3267 4.3. Bandwidth-Efficient Mode,分析前两个字节:
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  CMR  |F|  FT   |Q|  d(0)~d(n)
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    1 1 1 1 0 1 0 0 0 1 1 1 0 0 0 0 
CMR = 15
FT = 8

4. 参考资料

RTP Payload Format and File Storage Format for the AMR and AMR-WB Audio Codecs
https://www.rfc-editor.org/rfc/rfc3267.txt

AMR和AMR-WB帧结构
3GPP TS 26.101 Mandatory speech codec speech processing functions; AMR speech codec frame structure
3GPP TS 26.201 Speech codec speech processing functions; AMR-WB speech codec; Frame structure
AMR-WB数据生成方法
3GPP TS 26.190 Speech codec speech processing functions; AMR-WB speech codec; Transcoding functions

AMR在IP域中的编码(rfc3267,4867)
https://blog.csdn.net/runningya/article/details/6227384

Display Filter Reference: Adaptive Multi-Rate
https://www.wireshark.org/docs/dfref/a/amr.html
[Reserved != 0, wrongly encoded or not octet aligned. Decoding as bandwidth-efficient mode]

Audio File Formats - AMR
https://docs.fileformat.com/audio/amr/

RIFF和WAVE音频文件格式
https://www.cnblogs.com/wangguchangqing/p/5957531.htm

8 Best Hex Editors You Can Try
https://tech4fresher.com/best-hex-editors/
HEXED.IT - THE CLIENT-SIDE JAVASCRIPT BASED HEX EDITOR
https://hexed.it/
HXD Hex Editor
https://mh-nexus.de/en/downloads.php?product=HxD20

MediaInfo
https://mediaarea.net/en/MediaInfo

电脑提示调用DllRegisterServer失败解决方法【详细步骤】
https://product.pconline.com.cn/itbk/software/dnyw/1492/14920906.html

音频转换工具
https://www.freeconvert.com/audio-converter
https://convertio.co/zh/audio-converter/

标签:00,WB,Header,https,数据格式,AMR,Payload
From: https://www.cnblogs.com/wuhen1024/p/16823708.html

相关文章

  • 一文读懂rawRGB、RGB和YUV数据格式与转换
    rawRGB       图像采集的过程为:光照在成像物体被反射->镜头汇聚->Sensor光电转换->ADC转换为rawRGB因为sensor上每个像素只采集特定颜色的光的强度,......
  • windows server backup 无法使用或wbadmin.msc致命错误解决方法
    因为黑群辉断电无法自动引导进系统,我也找不到很好的办法,所以决定使用windowsserver来做NAS服务器,虽然都解决了内网穿透的问题,但是数据安全还在找方案,目前已经解决:1.购买......
  • C#使用StreamReader类和StreamWriter类读写文本文件
    StreamReader类和StreamWriter类可以实现读写文本文件,这两个类都在命名空间System.IO下。usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usi......
  • 网络通信——HTTP接口访问——移动数据格式JSON
        网络通信的交互数据格式有两大类,分别是JSON和XML。对于App来说,基本采用JSON格式与服务器通信。JSON相比XML的优势主要有两个:(1)手机流量很贵,表达同样的信息,J......
  • XML和JSON数据格式
    目录​​XML​​​​DTD(文档类型定义)​​​​DTD实体​​​​JSON​​​​使用python解析JSON数据​​​​XML和JSON的区别 ​​​​XML的优缺点​​​​JSON的优缺点​......
  • Excel日期数据格式不统一如何处理?
    Excel日期筛选格式混乱,Excel导入系统也报错,原因是格式错乱导致的,具体处理步骤如下:如何转为下图这种?操作步骤,如下 1、先选中如图所示整列 2、右键,设置单元格格式;自定义为yy......
  • HTTP——响应数据格式
    HTTP响应数据格式   状态码分类:  常见的状态响应码:    ......
  • 使用ViewBinding后button按钮失效
    今天学习《第一行代码》时使用ViewBinding代替findViewById(),发现代替以后button无法激活intent,从https://www.jianshu.com/p/86f780f3aabd找到了问题所在问题代码o......
  • FileStream,StreamReader,StreamWiter的用法
    https://blog.csdn.net/Good_StudyDaydayUp/article/details/82976951https://blog.csdn.net/linxinfa/article/details/95215416https://blog.csdn.net/qq_42778001/art......
  • Excel日期数据格式不统一如何处理?
    Excel日期筛选格式混乱,Excel导入系统也报错,原因是格式错乱导致的,具体处理步骤如下:如何转为下图这种?操作步骤,如下 1、先选中如图所示整列 2、右键,设置单元格格式;自......