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

Commit 6b41197a authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Steve Kondik
Browse files

libstagefright: Update handling of SBR explict siganlling

In case of SBR explict signalling in the bitstream, the core
AAC sample rate is overwritten by extension sample rate.
HW AAC decoder relies on core sample rate to parse the
bitstream when supplied in raw format.
Do not overwrite core sample rate but store it as separate
field in the meta data.

CRs-fixed: 572242

Change-Id: I5c70cfcc40a44bff9f9da4082c6b4dccd7c6788e
parent 500b863a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ enum {
    kKeyChannelCount      = '#chn',  // int32_t
    kKeyChannelMask       = 'chnm',  // int32_t
    kKeySampleRate        = 'srte',  // int32_t (audio sampling rate Hz)
    kKeyExtSampleRate     = 'exsr',  // int32_t (extenstion audio sampling rate Hz)
    kKeyFrameRate         = 'frmR',  // int32_t (video frame rate fps)
    kKeyBitRate           = 'brte',  // int32_t (bps)
    kKeyESDS              = 'esds',  // raw data
+23 −19
Original line number Diff line number Diff line
@@ -2325,6 +2325,10 @@ status_t MPEG4Extractor::verifyTrack(Track *track) {
status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
        const void *esds_data, size_t esds_size) {
    ESDS esds(esds_data, esds_size);
    static uint32_t kSamplingRate[] = {
        96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
        16000, 12000, 11025, 8000, 7350
    };

    uint8_t objectTypeIndication;
    if (esds.getObjectTypeIndication(&objectTypeIndication) != OK) {
@@ -2400,7 +2404,9 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
    uint32_t freqIndex = br.getBits(4);

    int32_t sampleRate = 0;
    int32_t extSampleRate = 0;
    int32_t numChannels = 0;

    if (freqIndex == 15) {
        if (csd_size < 5) {
            return ERROR_MALFORMED;
@@ -2408,30 +2414,27 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
        sampleRate = br.getBits(24);
        numChannels = br.getBits(4);
    } else {
        numChannels = br.getBits(4);
        if (objectType == 5) {
            // SBR specific config per 14496-3 table 1.13
            freqIndex = br.getBits(4);
            if (freqIndex == 15) {
                if (csd_size < 8) {
        if (freqIndex == 13 || freqIndex == 14) {
            return ERROR_MALFORMED;
        }
                sampleRate = br.getBits(24);
            }
        numChannels = br.getBits(4);
        sampleRate = kSamplingRate[freqIndex];
    }

        if (sampleRate == 0) {
            static uint32_t kSamplingRate[] = {
                96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
                16000, 12000, 11025, 8000, 7350
            };
    if (objectType == 5 || objectType == 29) {
        // SBR specific config per 14496-3 table 1.13
        freqIndex = br.getBits(4);

        if (freqIndex == 13 || freqIndex == 14) {
            return ERROR_MALFORMED;
        }

            sampleRate = kSamplingRate[freqIndex];
        if (freqIndex == 15) {
            if (csd_size < 8) {
                return ERROR_MALFORMED;
            }
            extSampleRate = br.getBits(24);
        }
        extSampleRate = kSamplingRate[freqIndex];
        mLastTrack->meta->setInt32(kKeyExtSampleRate, extSampleRate);
    }

    if (numChannels == 0) {
@@ -2447,6 +2450,7 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
    }

    mLastTrack->meta->setInt32(kKeySampleRate, sampleRate);
    mLastTrack->meta->setInt32(kKeyAACProfile, objectType);

    int32_t prevChannelCount;
    CHECK(mLastTrack->meta->findInt32(kKeyChannelCount, &prevChannelCount));