华为mate40会马赛克,但是华为mate9不会
public void decod(InputStream inputStream) {
int h264Read = 0;
int frameOffset = 0;
byte[] buffer = new byte[200000];
byte[] framebuffer = new byte[100000];
boolean readFlag = true;
while (!Thread.interrupted() && readFlag) {
try {
int length = inputStream.available();
if (length > 0) {
// Read file and fill buffer
int count = inputStream.read(buffer);
Log.i("count", "" + count);
h264Read += count;
Log.d("Read", "count:" + count + " h264Read:"
+ h264Read);
// Fill frameBuffer
if (frameOffset + count < 100000) {
System.arraycopy(buffer, 0, framebuffer,
frameOffset, count);
frameOffset += count;
} else {
frameOffset = 0;
System.arraycopy(buffer, 0, framebuffer,
frameOffset, count);
frameOffset += count;
}
if (receivedCallback != null) {
receivedCallback.callback(buffer, frameOffset, length);
}
// Find H264 head
Log.d("loop", "end loop");
} else {
h264Read = 0;
frameOffset = 0;
readFlag = false;
}
} catch (Exception e) {
e.printStackTrace();
}
try {
Thread.sleep(30);
} catch (InterruptedException e) {
}
}
我试过修改参数,但是还是会偶尔有马赛克