Merge "mm-audio: Update bitrate based on profile and samplerate"
diff --git a/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h b/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h
index 276eaa3..623caa8 100644
--- a/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h
+++ b/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
-Copyright (c) 2010, The Linux Foundation. All rights reserved.
+Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -358,7 +358,10 @@
OMX_COMPONENT_OUTPUT_DISABLE_PENDING =0x7
};
-
+ #define MIN_BITRATE 24000
+ #define MAX_BITRATE 192000
+ #define MAX_BITRATE_MULFACTOR 12
+ #define BITRATE_DIVFACTOR 2
typedef Map<OMX_BUFFERHEADERTYPE*, OMX_BUFFERHEADERTYPE*>
input_buffer_map;
@@ -619,6 +622,7 @@
OMX_U8 num_bits_reqd,
OMX_U32 value,
OMX_U16 *hdr_bit_index);
+ int get_updated_bit_rate(int bitrate);
};
#endif
diff --git a/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp b/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp
index 52aa915..6521265 100644
--- a/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp
+++ b/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
-Copyright (c) 2010, The Linux Foundation. All rights reserved.
+Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1438,10 +1438,12 @@
}
drv_aac_enc_config.channels = m_aac_param.nChannels;
drv_aac_enc_config.sample_rate = m_aac_param.nSampleRate;
- drv_aac_enc_config.bit_rate = m_aac_param.nBitRate;
- DEBUG_PRINT("aac config %lu,%lu,%lu %d\n",
+ drv_aac_enc_config.bit_rate =
+ get_updated_bit_rate(m_aac_param.nBitRate);
+ DEBUG_PRINT("aac config %lu,%lu,%lu %d updated bitrate %d\n",
m_aac_param.nChannels,m_aac_param.nSampleRate,
- m_aac_param.nBitRate,m_aac_param.eAACStreamFormat);
+ m_aac_param.nBitRate,m_aac_param.eAACStreamFormat,
+ drv_aac_enc_config.bit_rate);
switch(m_aac_param.eAACStreamFormat)
{
@@ -5014,3 +5016,44 @@
}
+int omx_aac_aenc::get_updated_bit_rate(int bitrate)
+{
+ int updated_rate, min_bitrate, max_bitrate;
+
+ max_bitrate = m_aac_param.nSampleRate *
+ MAX_BITRATE_MULFACTOR;
+ switch(m_aac_param.eAACProfile)
+ {
+ case OMX_AUDIO_AACObjectLC:
+ min_bitrate = m_aac_param.nSampleRate;
+ if (m_aac_param.nChannels == 1) {
+ min_bitrate = min_bitrate/BITRATE_DIVFACTOR;
+ max_bitrate = max_bitrate/BITRATE_DIVFACTOR;
+ }
+ break;
+ case OMX_AUDIO_AACObjectHE:
+ min_bitrate = MIN_BITRATE;
+ if (m_aac_param.nChannels == 1)
+ max_bitrate = max_bitrate/BITRATE_DIVFACTOR;
+ break;
+ case OMX_AUDIO_AACObjectHE_PS:
+ min_bitrate = MIN_BITRATE;
+ break;
+ default:
+ return bitrate;
+ break;
+ }
+ /* Update MIN and MAX values*/
+ if (min_bitrate > MIN_BITRATE)
+ min_bitrate = MIN_BITRATE;
+ if (max_bitrate > MAX_BITRATE)
+ max_bitrate = MAX_BITRATE;
+ /* Update the bitrate in the range */
+ if (bitrate < min_bitrate)
+ updated_rate = min_bitrate;
+ else if(bitrate > max_bitrate)
+ updated_rate = max_bitrate;
+ else
+ updated_rate = bitrate;
+ return updated_rate;
+}