交叉编译faac共享库
作者:咕唧咕唧liukun321
来自:http://blog.csdn.net/liukun321
Advanced Audio Coding。一种专为声音数据设计的文件压缩格式,与Mp3不同,它採用了全新的算法进行编码。更加高效,具有更高的“性价比”。
利用AAC格式,可使人感觉声音质量没有明显减少的前提下。更加小巧。
FAAC是在嵌入式系统中经常使用的AAC音频编码开源库。关于AAC音频格式能够看一下这篇博文作简单了解:AAC音频编码格式简析
FAAC开源project源代码下载链接:FAAC源代码下载
得到FAACproject源代码后首先运行 configure获得Makefile,并指定目标平台和交叉工具链
./configure--target=arm-linux--host=arm-none-linux-gnueabi
编译:
make
安装:
make install
终于会在指定安装文件夹获得例如以下动态及静态库:
libfaac.a
libfaac.la
libfaac.so
libfaac.so.0
libfaac.so.0.0.0
将获得的动态链接库放入开发板/usr/lib文件夹就可以
以下顺带附上一个将PCM 16bit 原始音频数据编码成AAC格式音频数据的C++类。以下的代码是从一个项目中抽取的。没有单独測试,仅做參考:
class AudioProcess {
public:
AudioProcess (void)
{
nSampleRate = RATE; // 採样率
nChannels = CHANNELS; // 声道数
nPCMBitSize = SIZE;
nInputSamples = 0;
nMaxOutputBytes = 0;
AACDecoderInitFlag = 0;
DecoderHandle = 0;
ADTSFrameInBuf = NULL;
PCMData = NULL;
ppBuffer = NULL;
}// var init
~AudioProcess(void)
{
}// var init
private:
ULONG nInputSamples ;
ULONG nMaxOutputBytes ;
faacEncHandle hEncoder;
faacEncConfigurationPtr pConfiguration;
BYTE* pbAACBuffer;
int nRet;
public:
int OutAACLength;
ULONG nSampleRate; // 採样率
UINT nChannels; // 声道数
UINT nPCMBitSize;
unsigned char* ppBuffer;
unsigned long pSizeOfDecoderSpecificInfo;
int nBytesRead;
int nPCMBufferSize;
int nAACBufferSize;
BYTE* pbPCMBuffer;
BYTE* OutAACBuffer;
public:
int AACEncoderInit();
int AACEncoding();
int AACEncoderDestory();
};
int AudioProcess ::AACEncoderInit()
{
hEncoder = faacEncOpen(nSampleRate, nChannels, &nInputSamples, &nMaxOutputBytes);
if(hEncoder == NULL)
{
printf("[ERROR] Failed to call faacEncOpen()\n");
return -1;
}
printf("nInputSamples = %d\n",nInputSamples);
nPCMBufferSize = nInputSamples * nPCMBitSize / 8;
pbPCMBuffer = new BYTE [nPCMBufferSize];
pbAACBuffer = new BYTE [nMaxOutputBytes]; // Get current encoding configuration
pConfiguration = faacEncGetCurrentConfiguration(hEncoder);
pConfiguration->inputFormat = FAAC_INPUT_16BIT;//_16BIT;
pConfiguration->mpegVersion = MPEG4;
pConfiguration->version = MPEG4; // 1
pConfiguration->outputFormat =1;// ADTS_STREAM; pConfiguration->aacObjectType = 2;//LOW;
pConfiguration->useTns = 0;//DEFAULT_TNS;
pConfiguration->shortctl = 0;//SHORTCTL_NORMAL;
pConfiguration->allowMidside = 1 ; // Set encoding configuration
nRet = faacEncSetConfiguration(hEncoder, pConfiguration);
faacEncGetDecoderSpecificInfo(hEncoder,&(ppBuffer), &(pSizeOfDecoderSpecificInfo));
} int AudioProcess ::AACEncoding()
{ // 输入样本数,用实际读入字节数计算,一般仅仅有读到文件尾时才不是 //nPCMBufferSize/(nPCMBitSize/8);
nBytesRead = length;
nInputSamples = nBytesRead / (nPCMBitSize / 8);
printf("nInputSamples = %d\n",nInputSamples); //Encode
nRet = faacEncEncode(hEncoder, (int*) pbPCMBuffer, nInputSamples, pbAACBuffer,nMaxOutputBytes);
OutAACBuffer = pbAACBuffer;
OutAACLength = nRet; return nRet;
} void AudioProcess::AACEncoderDestroy()
{
nRet = faacEncClose(hEncoder);
delete[] pbPCMBuffer;
delete[] pbAACBuffer; }
交叉编译faac共享库的更多相关文章
- 【转】交叉编译faac共享库
转自:http://blog.csdn.net/cjj198561/article/details/38382889 编译准备 1.代码下载 在mac下面执行:wget http://download ...
- Live555实战之交叉编译live555共享库
作者:咕唧咕唧liukun321 来自:http://blog.csdn.net/liukun321 能够通过这个链接获得最新的live555源代码:Live555源代码下载 Live555 是一个为 ...
- Linux学习笔记——如何使用共享库交叉编译
0.前言 在较为复杂的项目中会利用到交叉编译得到的共享库(*.so文件).在这样的情况下便会产生下面疑问,比如: [1]交叉编译时的共享库是否须要放置于目标板中,假设须要放置在哪个文件 ...
- Linux学习笔记——怎样在交叉编译时使用共享库
0.前言 在较为复杂的项目中会利用到交叉编译得到的共享库(*.so文件).在这样的情况下便会产生下面疑问,比如: [1]交叉编译时的共享库是否须要放置于目标板中,假设须要放置在哪个文件 ...
- Android NDK 交叉编译C++代码生成.so共享库详细步骤
Android NDK 交叉编译C++代码生成.so共享库详细步骤 Android NDK 调用c++ stl 模板库(修改android.mk文件) 1 在需要调用模板库的文件前包含头文件: ...
- C/C++ 跨平台交叉编译、静态库/动态库编译、MinGW、Cygwin、CodeBlocks使用原理及链接参数选项
目录 . 引言 . 交叉编译 . Cygwin简介 . 静态库编译及使用 . 动态库编译及使用 . MinGW简介 . CodeBlocks简介 0. 引言 UNIX是一个注册商标,是要满足一大堆条件 ...
- python调用c++/c 共享库,开发板上编译的一些坑!
1.对于python,ctypes只能load动态库,但现在我的对象是一个静态库,而且我没有源代码,静态库在编译过程中没有加--fPIC参数,所以我也没办法将其编译为动态库,有没有什么方法在pytho ...
- 链接(extern、static关键词\头文件\静态库\共享库)
原文链接:http://www.orlion.ga/781/ 一. 多目标文件的链接 假设有两个文件:stack.c: /* stack.c */ char stack[512]; int top = ...
- linux下共享库的注意点之-fpic
在编译共享库必须加上-fpic.这是为什么呢? 首先看一个简单的例子: #include <stdio.h> int fun1() { printf("fun1\n") ...
随机推荐
- To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]
Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31 ...
- 【转】ios蓝牙开发学习笔记(四)ios蓝牙应用的后台处理 -- 不错
原文网址:http://dev.ailab.cn/article-1038-220511-1.html 默认情况下,当应用进入后台或挂起时,蓝牙任务是不执行的.但是,你可以把应用声明为支持蓝牙后台执行 ...
- Python使用装饰器自动调用父类__init__
众所周知,Python中class的构造函数实际是__new__(),但是如果我们执行p1=Point()的时候,不仅会调用Point的__new__方法,而且会调用Point的__init__方法. ...
- 微阅读,不依赖playground,打包成H5版本--案例学习
微阅读,不依赖playground,打包成H5版本 https://github.com/vczero/weex-yy-h5
- js 数组包含
function(arr,element){ return new RegExp('(^|,)'+element.toString()+'(,|$)').test(arr.toString()); }
- B - Beautiful Year
Problem description It seems like the year of 2013 came only yesterday. Do you know a curious fact? ...
- Java 系列之spring学习--依赖注入(二)
一.依赖注入的三种方式 接口注入,set注入,构造函数注入 二.构造函数注入 2.1.测试类 package test; public class test01 { public String msg ...
- HashMap以及ConcurrentHashMap
HashMap源码相关 HashMap实现原理及源码分析 总之就是这个博客,简直就是源码带逛,开心,最关键的是下面的图像 另外,自己的理解加上源码,总结如下 hash,原义散列,就是一对一: hash ...
- mvc cshtml 中赋值
@{ var str = ""; str = item.ApplyStatus == ? ? ? ? "申请驳回" : ""; } < ...
- 优动漫PAINT发展历程和主要功能
优动漫PAINT也就是我们常说的clip studio paint(CSP)的中文版本,它是一款功能强大的动漫绘图软件.经过五年的成长,优动漫PAINT经历了从青涩到成熟的发展过程,随着软件更多功能的 ...