From 9aff25fb41f516ac26f9d1983a25402909f1e77a Mon Sep 17 00:00:00 2001 From: Leena Winterrowd Date: Tue, 4 Nov 2014 21:27:34 -0800 Subject: stagefright: httplive: Reduce memcpy calls for chunked content Streams using http chunking will not report the segment's total content-length. In this case, a 64k buffer is allocated and is increased by 32k each time the buffer is filled again. For high bitrate content, this can lead to a large number of copies that affect the HLS framework delay. Increase fetchFile buffer size exponentially by 50% or at least 32k instead of by 32k each time to reduce the number of memcpy calls. Example for a chunked 6 MB 1080p segment (ie ~3s): Adding 32k: 190 copies with 572.97 MB copied Increasing by 50%: 12 copies with 16.09 MB copied Bug: 18821145 Change-Id: Iedf0e4437e96026a58d50bce2660f85ac90d0ada --- media/libstagefright/httplive/LiveSession.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'media/libstagefright/httplive') diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index cad4c2d..e163985 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -873,7 +873,11 @@ ssize_t LiveSession::fetchFile( // Only resize when we don't know the size. size_t bufferRemaining = buffer->capacity() - buffer->size(); if (bufferRemaining == 0 && getSizeErr != OK) { - bufferRemaining = 32768; + size_t bufferIncrement = buffer->size() / 2; + if (bufferIncrement < 32768) { + bufferIncrement = 32768; + } + bufferRemaining = bufferIncrement; ALOGV("increasing download buffer to %zu bytes", buffer->size() + bufferRemaining); -- cgit v1.1