mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Fix handling of 3 byte Annex B start sequences
This commit is contained in:
parent
661edf2466
commit
f91787793e
@ -1 +1 @@
|
|||||||
Subproject commit 6001ece0b8bfcea6a8122a3e56f48f515e1aaaf5
|
Subproject commit e453a4d548559e216703a4f501ceede9b4952e12
|
12
viddec.cpp
12
viddec.cpp
@ -221,24 +221,24 @@ void MoonlightInstance::VidDecCleanup(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void WriteSpsNalu(PLENTRY nalu, unsigned char* outBuffer, unsigned int* offset) {
|
static void WriteSpsNalu(PLENTRY nalu, unsigned char* outBuffer, unsigned int* offset) {
|
||||||
const char naluHeader[] = {0x00, 0x00, 0x00, 0x01};
|
int start_len = nalu->data[2] == 0x01 ? 3 : 4;
|
||||||
h264_stream_t* stream = h264_new();
|
h264_stream_t* stream = h264_new();
|
||||||
|
|
||||||
// Read the old NALU
|
// Read the old NALU
|
||||||
read_nal_unit(stream,
|
read_nal_unit(stream,
|
||||||
(unsigned char *)&nalu->data[sizeof(naluHeader)],
|
(unsigned char *)&nalu->data[start_len],
|
||||||
nalu->length - sizeof(naluHeader));
|
nalu->length - start_len);
|
||||||
|
|
||||||
// Fixup the SPS to what OS X needs to use hardware acceleration
|
// Fixup the SPS to what OS X needs to use hardware acceleration
|
||||||
stream->sps->num_ref_frames = 1;
|
stream->sps->num_ref_frames = 1;
|
||||||
stream->sps->vui.max_dec_frame_buffering = 1;
|
stream->sps->vui.max_dec_frame_buffering = 1;
|
||||||
|
|
||||||
// Copy the NALU prefix over from the original SPS
|
// Copy the NALU prefix over from the original SPS
|
||||||
memcpy(&outBuffer[*offset], naluHeader, sizeof(naluHeader));
|
memcpy(&outBuffer[*offset], nalu->data, start_len);
|
||||||
*offset += sizeof(naluHeader);
|
*offset += start_len;
|
||||||
|
|
||||||
// Copy the modified NALU data
|
// Copy the modified NALU data
|
||||||
*offset += write_nal_unit(stream, &outBuffer[*offset], nalu->length + 32 - sizeof(naluHeader));
|
*offset += write_nal_unit(stream, &outBuffer[*offset], nalu->length + 32 - start_len);
|
||||||
|
|
||||||
h264_free(stream);
|
h264_free(stream);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user