From 1b95f027a220b3aaa5cace57c827e235aef88f20 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 5 Sep 2022 22:53:25 +0000 Subject: [PATCH] Fix handling of 3 byte Annex B start sequences --- libgamestream/sps.c | 8 ++++---- third_party/moonlight-common-c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libgamestream/sps.c b/libgamestream/sps.c index 6014f48..e502aa2 100644 --- a/libgamestream/sps.c +++ b/libgamestream/sps.c @@ -31,9 +31,9 @@ void gs_sps_init(int width, int height) { } void gs_sps_fix(PLENTRY sps, int flags, uint8_t* out_buf, uint32_t* out_offset) { - const char naluHeader[] = {0x00, 0x00, 0x00, 0x01}; + int start_len = sps->data[2] == 0x01 ? 3 : 4; - read_nal_unit(h264_stream, sps->data+4, sps->length-4); + read_nal_unit(h264_stream, sps->data+start_len, sps->length-start_len); // Some decoders rely on H264 level to decide how many buffers are needed // Since we only need one frame buffered, we'll set level as low as we can @@ -76,8 +76,8 @@ void gs_sps_fix(PLENTRY sps, int flags, uint8_t* out_buf, uint32_t* out_offset) h264_stream->sps->vui.max_bits_per_mb_denom = 1; } - memcpy(out_buf+*out_offset, naluHeader, 4); - *out_offset += 4; + memcpy(out_buf+*out_offset, sps->data, start_len); + *out_offset += start_len; *out_offset += write_nal_unit(h264_stream, out_buf+*out_offset, 128); } diff --git a/third_party/moonlight-common-c b/third_party/moonlight-common-c index e62dc56..e453a4d 160000 --- a/third_party/moonlight-common-c +++ b/third_party/moonlight-common-c @@ -1 +1 @@ -Subproject commit e62dc56047b038e5f2a5404b023fec453bf1bf8a +Subproject commit e453a4d548559e216703a4f501ceede9b4952e12