Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac022ed6 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm-audio: Update bitrate based on profile and samplerate"

parents 2f378012 f60ea3b3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
/*--------------------------------------------------------------------------
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 @@ private:
        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 @@ private:
                OMX_U8 num_bits_reqd,
                OMX_U32  value,
                OMX_U16 *hdr_bit_index);
    int get_updated_bit_rate(int bitrate);

};
#endif
+47 −4
Original line number Diff line number Diff line
/*--------------------------------------------------------------------------
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 @@ OMX_ERRORTYPE omx_aac_aenc::send_command_proxy(OMX_IN OMX_HANDLETYPE hComp,
                }
                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 @@ void omx_aac_aenc::audaac_rec_install_mp4ff_header_variable (OMX_U16 byte_num,

}

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;
}