From a39ad61a1c9c69c2cc60f5d14243dd56040f8571 Mon Sep 17 00:00:00 2001 From: John Grossman Date: Wed, 29 Aug 2012 14:51:01 -0700 Subject: Fix calculations for an obscure combo of MPEG audio options. MPEGv2 and MPEGv2.5 Layer 2 audio payloads should 1152 samples per access unit, not 576. Adjust the frame size and samples out calculations accordingly. Also, adjust the max frame size in the MP3Extractor's MediaSource to be closer to the theoretical worst case max frame size. The theoretical worst case for MPEG audio is 2881 bytes per frame, but the max frame size being used was 32kB. It has been changed to be 4kB in order to remain a power of 2 allocation, but to be the power of 2 closest to the worst case. Change-Id: If11f5a843b06e70151bbe8298cc54f954938d9d7 --- media/libstagefright/avc_utils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'media/libstagefright/avc_utils.cpp') diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp index 65c1848..a141752 100644 --- a/media/libstagefright/avc_utils.cpp +++ b/media/libstagefright/avc_utils.cpp @@ -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; } } -- cgit v1.1