板子helper2416 芯片是三星的s3c2416 arm平台 本机系统: opensuse
qtopia2.2中的播放mp4视频没有声音, 后来发现是没有aac音频解码
这就得从ffmpeg的源码中入手了,源码中有带了faac.c(编码), faad.c(解码),但是没有编译进去
进入目录
qtopia/src/3rdparty/libraries/libavcodec
查看版本
avcodec.h
// 可知对应ffmpeg的版本号
#define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1"
#define LIBAVCODEC_BUILD 4757
我们只要解码的,用来播放声音
faad.c
#include "avcodec.h"
#include "faad.h" // 这个头由faad库提供 得另外编译的
allcodecs.c
#ifdef CONFIG_FAAD
#ifdef CONFIG_AAC_DECODER
register_avcodec(&aac_decoder);
#endif //CONFIG_AAC_DECODER
要使能aad解码就得定义CONFIG_FAAD 与CONFIG_AAC_DECODER 两个宏
libavcodec.pri
CONFIG_VORBIS_DECODER
改成
CONFIG_VORBIS_DECODER \
CONFIG_FAAD \
CONFIG_AAC_DECODER
libavcodec.pro
contains(DEFINES,CONFIG_VORBIS_DECODER) {
SOURCES += vorbis.c
}
的后面加上
#JYX_MODI add
contains(DEFINES,CONFIG_AAC_DECODER) {
SOURCES += faad.c
INCLUDEPATH += ../libfaad2
PACKAGE_DEPENDS += libfaad2
LIBS += -lfaad
}
现在来把faad整合进去
faac库
http://www.audiocoding.com/faac.html
下载faad2-2.7.tar.bz2
解压faad
tar -xvf faad2-2.7.tar.bz2
cd faad2-2.7
./configure --host=arm-linux
cp include/* config.h libfaad/
修改libfaad/common.h
38行
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif
为
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
挎贝到qtopia源码目录中
cp libfaad/ ~/workspace/qtopia2.2/qtopia/src/3rdparty/libraries/libfaad2 -r
在libfaad2下新建个libfaad2.pro
TEMPLATE = lib
CONFIG -= qt
CONFIG -= warn_on
INCLUDEPATH += ./
DEPENDPATH += ./
DEFINES += HAVE_CONFIG_H
SOURCES += bits.c cfft.c decoder.c drc.c \
drm_dec.c error.c filtbank.c \
ic_predict.c is.c lt_predict.c \
mdct.c mp4.c ms.c output.c pns.c \
ps_dec.c ps_syntax.c \
pulse.c specrec.c syntax.c tns.c hcr.c huffman.c \
rvlc.c ssr.c ssr_fb.c ssr_ipqf.c common.c \
sbr_dct.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c \
sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c sbr_dec.c
TARGET = faad
DESTDIR = $$(QPEDIR)/lib
VERSION = 2.0.0
PACKAGE_NAME = libfaad2
qtopia/src/general.pri
约187行处
contains(PLUGIN_PROJECTS,3rdparty/plugins/codecs/libffmpeg) {
LIBRARY_PROJECTS+=\
3rdparty/libraries/libavcodec\
3rdparty/libraries/libavformat
}
改成
contains(PLUGIN_PROJECTS,3rdparty/plugins/codecs/libffmpeg) {
LIBRARY_PROJECTS+=\
3rdparty/libraries/libfaad2 \
3rdparty/libraries/libavcodec\
3rdparty/libraries/libavformat
}
qtopia/src/projects.pri
37行
LIBRARY_PROJECTS -= 3rdparty/libraries/libavcodec \
3rdparty/libraries/libavformat \
3rdparty/libraries/amr
改成
LIBRARY_PROJECTS -= 3rdparty/libraries/libavcodec \
3rdparty/libraries/libavformat \
3rdparty/libraries/libfaad2 \
3rdparty/libraries/amr
84行处
# only used with ffmpeg/amr
!contains(PLUGIN_PROJECTS,3rdparty/plugins/codecs/libffmpeg) {
!contains(PLUGIN_PROJECTS,3rdparty/plugins/codecs/libamr):LIBRARY_PROJECTS-=3rdparty/libraries/amr
LIBRARY_PROJECTS-=3rdparty/libraries/libavcodec\
3rdparty/libraries/libavformat
}
改成
# only used with ffmpeg/amr
!contains(PLUGIN_PROJECTS,3rdparty/plugins/codecs/libffmpeg) {
!contains(PLUGIN_PROJECTS,3rdparty/plugins/codecs/libamr):LIBRARY_PROJECTS-=3rdparty/libraries/amr
LIBRARY_PROJECTS-=3rdparty/libraries/libavcodec\
3rdparty/libraries/libfaad2 \
3rdparty/libraries/libavformat
}
重新编译就可以了. 更新了libfaad 与libavcodec, 如果有段错误,则libavcodec工程需要clean后再编译
作者:帅得不敢出门 c++哈哈堂群:31843264 转载请保留此信息