Removes a seemingly unnecessary allocation in .impl.media.codec.video.h264.Packetizer which causes a large number of garbage collections. There's still a lot to be desired there because the class is still a major offender in the area of owned garbage-collected objects with respect to size but the improvement is noticeable anyway.

cusax-fix
Lyubomir Marinov 17 years ago
parent cc373b375b
commit 3b10be78a0

@ -13,20 +13,18 @@
import javax.media.format.*;
import net.java.sip.communicator.impl.media.codec.*;
import net.java.sip.communicator.util.*;
import net.sf.fmj.media.*;
/**
* Packest supplied data and encapsulate it in rtp according
* rfc RFC3984.
* Packets supplied data and encapsulates it in RTP in accord with RFC3984.
*
* @author Damian Minkov
* @author Lubomir Marinov
*/
public class Packetizer
extends AbstractPacketizer
{
private final Logger logger = Logger.getLogger(Packetizer.class);
private final static String PLUGIN_NAME = "H264 Packetizer";
private Format[] supportedOutputFormats = null;
@ -218,31 +216,31 @@ public int process(Buffer inBuffer, Buffer outBuffer)
}
Format inFormat = inBuffer.getFormat();
if (inFormat != inputFormat && !(inFormat.matches(inputFormat)))
if (inFormat != inputFormat && !inFormat.matches(inputFormat))
{
setInputFormat(inFormat);
}
if (inBuffer.getLength() < 10)
int inputLength = inBuffer.getLength();
if (inputLength < 10)
{
outBuffer.setDiscard(true);
reset();
return BUFFER_PROCESSED_OK;
}
byte[] r = new byte[inBuffer.getLength()];
System.arraycopy(
inBuffer.getData(), inBuffer.getOffset(), r, 0, inBuffer.getLength());
byte[] r = (byte[]) inBuffer.getData();
int inputOffset = inBuffer.getOffset();
// split encoded data to nals
// we know it starts with 00 00 01
int ix = 3;
int prevIx = 1;
int ix = 3 + inputOffset;
int prevIx = 1 + inputOffset;
while((ix = ff_avc_find_startcode(r, ix, r.length)) < r.length)
{
int len = ix - prevIx;
byte[] b = new byte[len -4];
System.arraycopy(r, prevIx+ 3, b, 0, len-4);
System.arraycopy(r, prevIx+ 3, b, 0, b.length);
nals.add(b);
prevIx = ix;
@ -252,13 +250,12 @@ public int process(Buffer inBuffer, Buffer outBuffer)
int len = ix - prevIx;
if(len < 0)
{
logger.warn("aaaa");
outBuffer.setDiscard(true);
return BUFFER_PROCESSED_OK;
}
byte[] b = new byte[len - 3];
System.arraycopy(r, prevIx+ 3, b, 0, len-3);
System.arraycopy(r, prevIx+ 3, b, 0, b.length);
nals.add(b);
lastTimeStamp = inBuffer.getTimeStamp();

Loading…
Cancel
Save