mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-17 14:21:08 +00:00
Fix handling of 3 byte Annex B start sequences
This commit is contained in:
@@ -910,13 +910,14 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
int codecFlags = 0;
|
int codecFlags = 0;
|
||||||
|
|
||||||
// H264 SPS
|
// H264 SPS
|
||||||
if (decodeUnitData[4] == 0x67) {
|
if (decodeUnitType == MoonBridge.BUFFER_TYPE_SPS && (videoFormat & MoonBridge.VIDEO_FORMAT_MASK_H264) != 0) {
|
||||||
numSpsIn++;
|
numSpsIn++;
|
||||||
|
|
||||||
ByteBuffer spsBuf = ByteBuffer.wrap(decodeUnitData);
|
ByteBuffer spsBuf = ByteBuffer.wrap(decodeUnitData);
|
||||||
|
int startSeqLen = decodeUnitData[2] == 0x01 ? 3 : 4;
|
||||||
|
|
||||||
// Skip to the start of the NALU data
|
// Skip to the start of the NALU data
|
||||||
spsBuf.position(5);
|
spsBuf.position(startSeqLen + 1);
|
||||||
|
|
||||||
// The H264Utils.readSPS function safely handles
|
// The H264Utils.readSPS function safely handles
|
||||||
// Annex B NALUs (including NALUs with escape sequences)
|
// Annex B NALUs (including NALUs with escape sequences)
|
||||||
@@ -1020,9 +1021,9 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
ByteBuffer escapedNalu = H264Utils.writeSPS(sps, decodeUnitLength);
|
ByteBuffer escapedNalu = H264Utils.writeSPS(sps, decodeUnitLength);
|
||||||
|
|
||||||
// Batch this to submit together with PPS
|
// Batch this to submit together with PPS
|
||||||
spsBuffer = new byte[5 + escapedNalu.limit()];
|
spsBuffer = new byte[startSeqLen + 1 + escapedNalu.limit()];
|
||||||
System.arraycopy(decodeUnitData, 0, spsBuffer, 0, 5);
|
System.arraycopy(decodeUnitData, 0, spsBuffer, 0, startSeqLen + 1);
|
||||||
escapedNalu.get(spsBuffer, 5, escapedNalu.limit());
|
escapedNalu.get(spsBuffer, startSeqLen + 1, escapedNalu.limit());
|
||||||
return MoonBridge.DR_OK;
|
return MoonBridge.DR_OK;
|
||||||
}
|
}
|
||||||
else if (decodeUnitType == MoonBridge.BUFFER_TYPE_VPS) {
|
else if (decodeUnitType == MoonBridge.BUFFER_TYPE_VPS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user