From 0c19cf7478f4dc10f2739bf6eefa1887a79b48cf Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Sat, 12 Dec 2015 21:28:57 -0800 Subject: stagefright: Add support for FLAC offloading * New Qualcomm DSPs support FLAC decoding, but the offload code is stubbed out in M. Unstub it from what used to be open source. Change-Id: I03c129c42ebc6909a3392e42a7f96791c8fabd28 --- media/libavextensions/Android.mk | 6 ++++++ media/libavextensions/mediaplayerservice/AVNuUtils.cpp | 3 +++ media/libavextensions/stagefright/AVExtensions.h | 2 +- media/libavextensions/stagefright/AVUtils.cpp | 17 +++++++++++++---- 4 files changed, 23 insertions(+), 5 deletions(-) (limited to 'media/libavextensions') diff --git a/media/libavextensions/Android.mk b/media/libavextensions/Android.mk index a39a76e..8099ad4 100644 --- a/media/libavextensions/Android.mk +++ b/media/libavextensions/Android.mk @@ -17,9 +17,15 @@ LOCAL_C_INCLUDES:= \ LOCAL_CFLAGS += -Wno-multichar -Werror +ifeq ($(call is-vendor-board-platform,QCOM),true) +LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio ifeq ($(TARGET_ENABLE_QC_AV_ENHANCEMENTS),true) LOCAL_CFLAGS += -DENABLE_AV_ENHANCEMENTS endif +ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FLAC_OFFLOAD)),true) + LOCAL_CFLAGS += -DFLAC_OFFLOAD_ENABLED +endif +endif LOCAL_MODULE:= libavextensions LOCAL_CFLAGS += -DLOG_NDEBUG=0 diff --git a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp index 8a78767..c475fd3 100644 --- a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp +++ b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp @@ -228,6 +228,9 @@ void AVNuUtils::setPCMFormat(const sp &format, audio_format_t audioFor } void AVNuUtils::setSourcePCMFormat(const sp &audioMeta) { + if (!isRAWFormat(audioMeta)) + return; + audio_format_t pcmFormat = getKeyPCMFormat(audioMeta); ALOGI("setSourcePCMFormat fmt=%x", pcmFormat); audioMeta->dumpToLog(); diff --git a/media/libavextensions/stagefright/AVExtensions.h b/media/libavextensions/stagefright/AVExtensions.h index 0b70c08..9474d19 100644 --- a/media/libavextensions/stagefright/AVExtensions.h +++ b/media/libavextensions/stagefright/AVExtensions.h @@ -35,10 +35,10 @@ #include #include #include +#include namespace android { -class AudioParameter; class MetaData; class MediaExtractor; class MPEG4Writer; diff --git a/media/libavextensions/stagefright/AVUtils.cpp b/media/libavextensions/stagefright/AVUtils.cpp index c36e0bb..02648fb 100644 --- a/media/libavextensions/stagefright/AVUtils.cpp +++ b/media/libavextensions/stagefright/AVUtils.cpp @@ -42,6 +42,9 @@ #ifdef QCOM_HARDWARE #include "QCMediaDefs.h" #include "QCMetaData.h" +#ifdef FLAC_OFFLOAD_ENABLED +#include "audio_defs.h" +#endif #endif #include "common/ExtensionsLoader.hpp" @@ -84,6 +87,12 @@ static const MetaKeyEntry MetaKeyTable[] { {kKeyUseArbitraryMode , "use-arbitrary-mode" , INT32}, //bool (int32_t) {kKeySmoothStreaming , "smooth-streaming" , INT32}, //bool (int32_t) {kKeyHFR , "hfr" , INT32}, // int32_t +#ifdef FLAC_OFFLOAD_ENABLED + {kKeyMinBlkSize , "min-block-size" , INT32}, + {kKeyMaxBlkSize , "max-block-size" , INT32}, + {kKeyMinFrmSize , "min-frame-size" , INT32}, + {kKeyMaxFrmSize , "max-frame-size" , INT32}, +#endif #endif @@ -221,16 +230,16 @@ status_t AVUtils::sendMetaDataToHal( #ifdef FLAC_OFFLOAD_ENABLED int32_t minBlkSize, maxBlkSize, minFrmSize, maxFrmSize; //FLAC params if (meta->findInt32(kKeyMinBlkSize, &minBlkSize)) { - param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE), minBlkSize); + param->addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE), minBlkSize); } if (meta->findInt32(kKeyMaxBlkSize, &maxBlkSize)) { - param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE), maxBlkSize); + param->addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE), maxBlkSize); } if (meta->findInt32(kKeyMinFrmSize, &minFrmSize)) { - param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE), minFrmSize); + param->addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE), minFrmSize); } if (meta->findInt32(kKeyMaxFrmSize, &maxFrmSize)) { - param.addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE), maxFrmSize); + param->addInt(String8(AUDIO_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE), maxFrmSize); } #else (void)meta; -- cgit v1.1