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

Commit c56857b4 authored by John Grossman's avatar John Grossman Committed by Android (Google) Code Review
Browse files

Merge "Fix calculations for an obscure combo of MPEG audio options." into jb-mr1-dev

parents 96150cfc a39ad61a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ protected:
    virtual ~MP3Source();

private:
    static const size_t kMaxFrameSize;
    sp<MetaData> mMeta;
    sp<DataSource> mDataSource;
    off64_t mFirstFramePos;
@@ -405,6 +406,13 @@ sp<MetaData> MP3Extractor::getTrackMetaData(size_t index, uint32_t flags) {

////////////////////////////////////////////////////////////////////////////////

// The theoretical maximum frame size for an MPEG audio stream should occur
// while playing a Layer 2, MPEGv2.5 audio stream at 160kbps (with padding).
// The size of this frame should be...
// ((1152 samples/frame * 160000 bits/sec) /
//  (8000 samples/sec * 8 bits/byte)) + 1 padding byte/frame = 2881 bytes/frame.
// Set our max frame size to the nearest power of 2 above this size (aka, 4kB)
const size_t MP3Source::kMaxFrameSize = (1 << 12); /* 4096 bytes */
MP3Source::MP3Source(
        const sp<MetaData> &meta, const sp<DataSource> &source,
        off64_t first_frame_pos, uint32_t fixed_header,
@@ -433,7 +441,6 @@ status_t MP3Source::start(MetaData *) {

    mGroup = new MediaBufferGroup;

    const size_t kMaxFrameSize = 32768;
    mGroup->add_buffer(new MediaBuffer(kMaxFrameSize));

    mCurrentPos = mFirstFramePos;
+3 −2
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ bool GetMPEGAudioFrameSize(

            bitrate = kBitrateV2[bitrate_index - 1];
            if (out_num_samples) {
                *out_num_samples = 576;
                *out_num_samples = (layer == 1 /* L3 */) ? 576 : 1152;
            }
        }

@@ -612,7 +612,8 @@ bool GetMPEGAudioFrameSize(
            *frame_size = 144000 * bitrate / sampling_rate + padding;
        } else {
            // V2 or V2.5
            *frame_size = 72000 * bitrate / sampling_rate + padding;
            size_t tmp = (layer == 1 /* L3 */) ? 72000 : 144000;
            *frame_size = tmp * bitrate / sampling_rate + padding;
        }
    }