Don't overwrite next NAL during SPS fix

This commit is contained in:
Iwan Timmer
2014-01-17 15:41:34 +01:00
parent 69761e84cd
commit f33ed3dbe1

View File

@@ -51,17 +51,24 @@ public class OmxDecoderRenderer implements VideoDecoderRenderer {
int shift = (Integer.numberOfLeadingZeros(last & - last) - 1)%8;
int bitstream_restriction = BITSTREAM_RESTRICTIONS >>> shift;
boolean twoBytes = shift==7;
int index = header.length + header.offset - (twoBytes?2:1);
header.data[index] = (byte) (((int) header.data[index] & 0xFF) | (bitstream_restriction >>> 24));
header.data[index+1] = (byte) ((twoBytes?((int) header.data[index+1] & 0xFF):0) | (bitstream_restriction >>> 16));
header.data[index+2] = (byte) (bitstream_restriction >>> 8);
int index = header.length - (twoBytes?2:1);
header.length += twoBytes?1:2;
if (Integer.numberOfTrailingZeros(bitstream_restriction) < 8) {
header.data[index+3] = (byte) (bitstream_restriction);
if (Integer.numberOfTrailingZeros(bitstream_restriction) < 8)
header.length++;
}
byte[] newArray = new byte[header.length];
System.arraycopy(header.data, header.offset, newArray, 0, header.length-1);
newArray[index] = (byte) (((int) header.data[index + header.offset] & 0xFF) | (bitstream_restriction >>> 24));
newArray[index+1] = (byte) ((twoBytes?((int) header.data[index+1 + header.offset] & 0xFF):0) | (bitstream_restriction >>> 16));
newArray[index+2] = (byte) (bitstream_restriction >>> 8);
if (Integer.numberOfTrailingZeros(bitstream_restriction) < 8)
newArray[index+3] = (byte) (bitstream_restriction);
header.data = newArray;
header.offset = 0;
}
for (int i=0;i<units.size();i++) {