我没有怎么搜Google关于ape文件格式,一来好像不是很多(或是我没搜到),另一方面是因为下载了Monkey's Audio Codec 的SDK后,里面有定义,所以就自己钻研起来。

原文是酱紫的

APE File Format Overview: (pieces in order -- only valid for the latest version APE files)

JUNK - any amount of "junk" before the APE_DESCRIPTOR (so people that put ID3v2 tags on the files aren't hosed)

APE_DESCRIPTOR - defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum

APE_HEADER - describes all of the necessary information about the APE file

SEEK TABLE - the table that represents seek offsets [optional]

HEADER DATA - the pre-audio data from the original file [optional]

APE FRAMES - the actual compressed audio (broken into frames for seekability)

TERMINATING DATA - the post-audio data from the original file [optional]

TAG - describes all the properties of the file [optional]

但是我没有太理解。看下去,(注意,这个头文件定义了 #pragma pach(4),结构体以4字节对齐,这个编译选项是vc的,我用gcc的= =)

/*****************************************************************************************
WAV header structure
*****************************************************************************************/
struct WAVE_HEADER
{// RIFF headerchar cRIFFHeader[4];unsigned int nRIFFBytes;// data typechar cDataTypeID[4];// wave formatchar cFormatHeader[4];unsigned int nFormatBytes;unsigned short nFormatTag;unsigned short nChannels;unsigned int nSamplesPerSec;unsigned int nAvgBytesPerSec;unsigned short nBlockAlign;unsigned short nBitsPerSample;// data chunk headerchar cDataHeader[4];unsigned int nDataBytes;
};

这里就很明显了,这个是 RIFF的文件格式,是 wave文件的头。

我找了一个wav的文件,在linux下用od查看头60个字节(为什么是60?我参考了http://www.cnblogs.com/filamm/archive/2008/08/07/1248821.html 注意后面的评论,我无法决断):

styx@paradiso:~$ od -c cupwav0000.wav -N 60
0000000   R   I   F   F 344 243  \a  \0   W   A   V   E   f   m   t
0000020 020  \0  \0  \0 001  \0 001  \0   "   V  \0  \0   D 254  \0  \0
0000040 002  \0 020  \0   f   a   c   t 004  \0  \0  \0 332 321 003  \0
0000060   d   a   t   a 264 243  \a  \0   # 322   ( 326
0000074

依照上面链接中的解释,基本上是符合的,后面也有那个fact块和data块。

同样我找了一个ape文件,用od查看头52个字节(因为文件头是4字节对齐,所以数一下就知道了),但是我错了。。。:

styx@paradiso:~$ od -c 01\ Never\ Grow\ Old.ape -N 52
0000000   M   A   C     226 017  \0  \0   4  \0  \0  \0 030  \0  \0  \0
0000020   x 001  \0  \0 034 001  \0  \0 270 272 361  \0  \0  \0  \0  \0
0000040  \0  \0  \0  \0 326   m 226 215 347   K 021   : 340 310 220 270
0000060 203   } 240   '
0000064

除了最开头可以看成是MAC的标志,后面的数据跟这个头完全配不上,想起来那个原文的描述,才知道自己不错才怪了= =

然后递增字节个数,差不多到600的时候可以看到了:

(省略前后)

0000660   g 330 354  \0 221 256 356  \0   - 017 360  \0   3 033 361  \0
0000700 210 275 361  \0   R   I   F   F 024 350 244 001   W   A   V   E
0000720   L   I   S   T 346  \0  \0  \0   I   N   F   O   I   A   R   T
0000740 020  \0  \0  \0   T   h   e       C   r   a   n   b   e   r   r
0000760   i   e   s  \0   I   N   A   M 017  \0  \0  \0   N   e   v   e
0001000   r       G   r   o   w       O   l   d  \0  \0   I   P   R   D
0001020   /  \0  \0  \0   W   a   k   e       U   p       a   n   d
0001040   S   m   e   l   l       t   h   e       C   o   f   f   e   e
0001060       [   B   o   n   u   s       C   D   ]       D   i   s   c
0001100       1  \0  \0   I   G   N   R 004  \0  \0  \0   P   o   p  \0

能从这里看到那个“RIFF”标志,也看到了WAVE,但是依然不符合WAVE文件头。看了源代码才知道:

/*****************************************************************************************
APE_DESCRIPTOR structure (file header that describes lengths, offsets, etc.)
*****************************************************************************************/
struct APE_DESCRIPTOR
{char   cID[4];                             // should equal 'MAC 'uint16 nVersion;                           // version number * 1000 (3.81 = 3810) (remember that 4-byte alignment causes this to take 4-bytes)uint32 nDescriptorBytes;                   // the number of descriptor bytes (allows later expansion of this header)uint32 nHeaderBytes;                       // the number of header APE_HEADER bytesuint32 nSeekTableBytes;                    // the number of bytes of the seek tableuint32 nHeaderDataBytes;                   // the number of header data bytes (from original file)uint32 nAPEFrameDataBytes;                 // the number of bytes of APE frame datauint32 nAPEFrameDataBytesHigh;             // the high order number of APE frame data bytesuint32 nTerminatingDataBytes;              // the terminating data of the file (not including tag data)uint8  cFileMD5[16];                       // the MD5 hash of the file (see notes for usage... it's a littly tricky)
};/*****************************************************************************************
APE_HEADER structure (describes the format, duration, etc. of the APE file)
*****************************************************************************************/
struct APE_HEADER
{uint16 nCompressionLevel;                 // the compression level (see defines I.E. COMPRESSION_LEVEL_FAST)uint16 nFormatFlags;                      // any format flags (for future use)uint32 nBlocksPerFrame;                   // the number of audio blocks in one frameuint32 nFinalFrameBlocks;                 // the number of audio blocks in the final frameuint32 nTotalFrames;                      // the total number of framesuint16 nBitsPerSample;                    // the bits per sample (typically 16)uint16 nChannels;                         // the number of channels (1 or 2)uint32 nSampleRate;                       // the sample rate (typically 44100)
};

(代码贴得太长了)

APE文件学习——文件头(1)相关推荐

  1. 各类文件的文件头标志[转]

    各类文件的文件头标志 参见  http://www.garykessler.net/library/file_sigs.html 扩展名 文件头标识(HEX) 文件描述 123 00 00 1A 00 ...

  2. java 文件头_常用文件的文件头(附JAVA测试类)

    1. MIDI (mid),文件头:4D546864 2. JPEG (jpg),文件头:FFD8FF 3. PNG (png),文件头:89504E47 4. GIF (gif),文件头:47494 ...

  3. html的文件头标志,各类文件的文件头标志.docx

    各类文件的文件头标志.docx 还剩 12页未读, 继续阅读 下载文档到电脑,马上远离加班熬夜! 亲,很抱歉,此页已超出免费预览范围啦! 如果喜欢就下载吧,价低环保! 内容要点: 扩展名 文件头标识( ...

  4. html的文件头标志,各类文件的文件头标志.doc

    各类文件的文件头标志 1.从Ultra-edit-32中提取出来的 JPEG (jpg),文件头:FFD8FF PNG (png),文件头:89504E47 GIF (gif),文件头TIFF (ti ...

  5. Shapefile文件读取-文件头

    1 介绍 在Shapefile文件格式介绍一文中我们介绍了shapefile文件的结构组成,本文主要介绍如何读取shapefile文件头部分,使用的语言是c++. 2 文件头结构 Shapefile文 ...

  6. clamav的病毒库文件的文件头的信息说明(clamav版本号等)

    Author : Samson Date : 01/04/2022 在开源病毒检测工具clamav中,是通过对病毒库中的病毒特征值来进行对比的,病毒库文件存放于/var/lib/clamav目录下,主 ...

  7. 程序的本质之二ELF文件的文件头、section header和program header

    操作系统:CentOS Linux release 7.7.1908 内核版本:3.10.0-1062.1.1.el7.x86_64 运行平台:x86_64 参考文献:http://refspecs. ...

  8. 各种常见文件的文件头及其含义

    根据文件的后缀名识别文件类型并不准确,可以使用文件的头信息进行识别: 以下是各类文件的头: JPEG (jpg),文件头:FFD8FFE1 PNG (png),文件头:89504E47 GIF (gi ...

  9. PE文件解析-文件头与整体介绍

    一.PE的基本概念 PE(Portable Execute)文件是Windows下可执行文件的总称,常见的有DLL,EXE,OCX,SYS等,事实上,一个文件是否是PE文件与其扩展名无关,PE文件可以 ...

最新文章

  1. 3人2周上线,2人1周上线,Solo明天上线!开发周期果然不能用搬砖模式计算......
  2. eclipse中导入spring-boot框架的jar包方法
  3. 用栈实现队列与用队列实现栈
  4. yii2中的事件和行为
  5. 终于……我的游戏………简体版就要发布了!
  6. Alluxio:2022年大数据五大趋势,多云下数据湖兴起,AI成为主流
  7. Android用户界面 UI组件--TextView及其子类(二) Button,selector选择器,sharp属性
  8. scrapy 处理动态加载,使用phantomjs
  9. 中国 X86 服务器市场 10 年来首次负增长
  10. mysql 事务_MySQL事务隔离级别
  11. 松花江等三流域禁渔效果不理想 跨界水域成管理盲区
  12. beyond 注册表删除
  13. DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unico
  14. 解析SRAM存储容量及基本特点
  15. 【电气专业知识问答】问:电动机的电气性能有什么要求?
  16. 不同局域网下共享打印机的解决思路(保证可用)
  17. 点餐系统-----数据库设计
  18. nginx逻辑指令笔记(if等)
  19. 基于 STM32对音频数据的 Flash 读取与 DAC 播放
  20. 蜗牛学院:项目管理十大TION法

热门文章

  1. android studio导入第三方库引发的问题和解决方法
  2. 防雷接地国家规范标准介绍与施工技术要点
  3. python量化实战 顾比倒数线_龙腾四海:顾比倒数线+顾比均线
  4. 理财APP有哪些维度可向用户推荐理财产品
  5. unity 上架google play 包体超过150M
  6. 2021程序员必看面试指南-进大厂年薪百万需要付出多少努力?你看看你们配吗......
  7. 【加量不加价,提供只读脚本】小麦苗健康检查脚本说明(Oracle巡检脚本)
  8. 用Python搓一个太阳系
  9. Wopus问答第一期
  10. 操作系统——(9)磁盘存储器的管理