diff --git a/app/libs/limelight-common.jar b/app/libs/limelight-common.jar index d4f62332..e92cd709 100644 Binary files a/app/libs/limelight-common.jar and b/app/libs/limelight-common.jar differ diff --git a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java index 69b9b6dc..e5a286ce 100644 --- a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java +++ b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java @@ -486,19 +486,49 @@ public class MediaCodecDecoderRenderer extends EnhancedDecoderRenderer { LimeLog.info("Patching num_ref_frames in SPS"); sps.num_ref_frames = 1; + // GFE 2.5.11 changed the SPS to add additional extensions + // Some devices don't like these so we remove them here. + sps.vuiParams.video_signal_type_present_flag = false; + sps.vuiParams.colour_description_present_flag = false; + sps.vuiParams.colour_primaries = 2; + sps.vuiParams.transfer_characteristics = 2; + sps.vuiParams.matrix_coefficients = 2; + sps.vuiParams.chroma_loc_info_present_flag = false; + sps.vuiParams.chroma_sample_loc_type_bottom_field = 0; + sps.vuiParams.chroma_sample_loc_type_top_field = 0; + if (needsSpsBitstreamFixup || isExynos4) { // The SPS that comes in the current H264 bytestream doesn't set bitstream_restriction_flag // or max_dec_frame_buffering which increases decoding latency on Tegra. - LimeLog.info("Adding bitstream restrictions"); - sps.vuiParams.bitstreamRestriction = new VUIParameters.BitstreamRestriction(); - sps.vuiParams.bitstreamRestriction.motion_vectors_over_pic_boundaries_flag = true; + // GFE 2.5.11 started sending bitstream restrictions + if (sps.vuiParams.bitstreamRestriction == null) { + LimeLog.info("Adding bitstream restrictions"); + sps.vuiParams.bitstreamRestriction = new VUIParameters.BitstreamRestriction(); + sps.vuiParams.bitstreamRestriction.motion_vectors_over_pic_boundaries_flag = true; + sps.vuiParams.bitstreamRestriction.log2_max_mv_length_horizontal = 16; + sps.vuiParams.bitstreamRestriction.log2_max_mv_length_vertical = 16; + sps.vuiParams.bitstreamRestriction.num_reorder_frames = 0; + } + else { + LimeLog.info("Patching bitstream restrictions"); + } + + // Some devices throw errors if max_dec_frame_buffering < num_ref_frames + sps.vuiParams.bitstreamRestriction.max_dec_frame_buffering = sps.num_ref_frames; + + // These values are the defaults for the fields, but they are more aggressive + // than what GFE sends in 2.5.11, but it doesn't seem to cause picture problems. sps.vuiParams.bitstreamRestriction.max_bytes_per_pic_denom = 2; sps.vuiParams.bitstreamRestriction.max_bits_per_mb_denom = 1; - sps.vuiParams.bitstreamRestriction.log2_max_mv_length_horizontal = 16; - sps.vuiParams.bitstreamRestriction.log2_max_mv_length_vertical = 16; - sps.vuiParams.bitstreamRestriction.num_reorder_frames = 0; - sps.vuiParams.bitstreamRestriction.max_dec_frame_buffering = 1; + + // log2_max_mv_length_horizontal and log2_max_mv_length_vertical are set to more + // conservative values by GFE 2.5.11. We'll let those values stand. + } + else { + // Devices that didn't/couldn't get bitstream restrictions before GFE 2.5.11 + // will continue to not receive them now + sps.vuiParams.bitstreamRestriction = null; } // If we need to hack this SPS to say we're baseline, do so now