From ef39fc70d9643b000d7161725de7b1bd8faca5c7 Mon Sep 17 00:00:00 2001 From: dancho Date: Fri, 2 May 2025 06:14:30 -0700 Subject: [PATCH] Disable codec reuse when only crop rect changes Work around a bug where MediaCodec fails to adapt between formats that have the same decoded picture resolution but different crop. Add a playlist of two MP4 files that reproduce the issue. This CL implements the workaround for H.265 and Mp4 PiperOrigin-RevId: 753976872 --- demos/main/src/main/assets/media.exolist.json | 11 +++ .../java/androidx/media3/common/Format.java | 67 +++++++++++++++++++ .../media3/container/NalUnitUtil.java | 27 ++++++-- .../exoplayer/mediacodec/MediaCodecInfo.java | 16 ++++- .../mediacodec/MediaCodecInfoTest.java | 19 ++++++ .../androidx/media3/extractor/HevcConfig.java | 20 +++++- .../media3/extractor/mp4/BoxParser.java | 6 ++ ...ixel-motion-photo-2-hevc-tracks.jpg.0.dump | 4 ++ ...ixel-motion-photo-2-hevc-tracks.jpg.1.dump | 4 ++ ...ixel-motion-photo-2-hevc-tracks.jpg.2.dump | 4 ++ ...ixel-motion-photo-2-hevc-tracks.jpg.3.dump | 4 ++ .../mp4/fragmented_captions_h265.mp4.0.dump | 2 + ...ding_within_gop_sample_dependencies.0.dump | 2 + ...op_sample_dependencies.unknown_length.dump | 2 + ...nted_captions_h265.mp4.unknown_length.dump | 2 + .../mp4/h265_bframes.mp4.0.dump | 2 + .../mp4/h265_bframes.mp4.1.dump | 2 + .../mp4/h265_bframes.mp4.2.dump | 2 + .../mp4/h265_bframes.mp4.3.dump | 2 + ...ding_within_gop_sample_dependencies.0.dump | 2 + ...ding_within_gop_sample_dependencies.1.dump | 2 + ...ding_within_gop_sample_dependencies.2.dump | 2 + ...ding_within_gop_sample_dependencies.3.dump | 2 + ...op_sample_dependencies.unknown_length.dump | 2 + .../mp4/h265_bframes.mp4.unknown_length.dump | 2 + ...ixel-motion-photo-2-hevc-tracks.mp4.0.dump | 4 ++ ...ixel-motion-photo-2-hevc-tracks.mp4.1.dump | 4 ++ ...ixel-motion-photo-2-hevc-tracks.mp4.2.dump | 4 ++ ...ixel-motion-photo-2-hevc-tracks.mp4.3.dump | 4 ++ ...ding_within_gop_sample_dependencies.0.dump | 4 ++ ...ding_within_gop_sample_dependencies.1.dump | 4 ++ ...ding_within_gop_sample_dependencies.2.dump | 4 ++ ...ding_within_gop_sample_dependencies.3.dump | 4 ++ ...op_sample_dependencies.unknown_length.dump | 4 ++ ...hoto-2-hevc-tracks.mp4.unknown_length.dump | 4 ++ .../mp4/sample_edit_list.mp4.0.dump | 2 + .../mp4/sample_edit_list.mp4.1.dump | 2 + .../mp4/sample_edit_list.mp4.2.dump | 2 + .../mp4/sample_edit_list.mp4.3.dump | 2 + ...ding_within_gop_sample_dependencies.0.dump | 2 + ...ding_within_gop_sample_dependencies.1.dump | 2 + ...ding_within_gop_sample_dependencies.2.dump | 2 + ...ding_within_gop_sample_dependencies.3.dump | 2 + ...op_sample_dependencies.unknown_length.dump | 2 + .../sample_edit_list.mp4.unknown_length.dump | 2 + ..._list_no_sync_frame_before_edit.mp4.0.dump | 2 + ..._list_no_sync_frame_before_edit.mp4.1.dump | 2 + ..._list_no_sync_frame_before_edit.mp4.2.dump | 2 + ..._list_no_sync_frame_before_edit.mp4.3.dump | 2 + ...ding_within_gop_sample_dependencies.0.dump | 2 + ...ding_within_gop_sample_dependencies.1.dump | 2 + ...ding_within_gop_sample_dependencies.2.dump | 2 + ...ding_within_gop_sample_dependencies.3.dump | 2 + ...op_sample_dependencies.unknown_length.dump | 2 + ..._frame_before_edit.mp4.unknown_length.dump | 2 + .../mp4/sample_with_color_info.mp4.0.dump | 2 + .../mp4/sample_with_color_info.mp4.1.dump | 2 + .../mp4/sample_with_color_info.mp4.2.dump | 2 + .../mp4/sample_with_color_info.mp4.3.dump | 2 + ...ding_within_gop_sample_dependencies.0.dump | 2 + ...ding_within_gop_sample_dependencies.1.dump | 2 + ...ding_within_gop_sample_dependencies.2.dump | 2 + ...ding_within_gop_sample_dependencies.3.dump | 2 + ...op_sample_dependencies.unknown_length.dump | 2 + ...le_with_color_info.mp4.unknown_length.dump | 2 + ...riginal_quicktime_specification.mov.0.dump | 2 + ...riginal_quicktime_specification.mov.1.dump | 2 + ...riginal_quicktime_specification.mov.2.dump | 2 + ...riginal_quicktime_specification.mov.3.dump | 2 + ...ding_within_gop_sample_dependencies.0.dump | 2 + ...ding_within_gop_sample_dependencies.1.dump | 2 + ...ding_within_gop_sample_dependencies.2.dump | 2 + ...ding_within_gop_sample_dependencies.3.dump | 2 + ...op_sample_dependencies.unknown_length.dump | 2 + ...time_specification.mov.unknown_length.dump | 2 + .../mp4/water_180_mvhevc_5frames.mov.0.dump | 2 + .../mp4/water_180_mvhevc_5frames.mov.1.dump | 2 + .../mp4/water_180_mvhevc_5frames.mov.2.dump | 2 + .../mp4/water_180_mvhevc_5frames.mov.3.dump | 2 + ...ding_within_gop_sample_dependencies.0.dump | 2 + ...ding_within_gop_sample_dependencies.1.dump | 2 + ...ding_within_gop_sample_dependencies.2.dump | 2 + ...ding_within_gop_sample_dependencies.3.dump | 2 + ...op_sample_dependencies.unknown_length.dump | 2 + ...180_mvhevc_5frames.mov.unknown_length.dump | 2 + .../h265_with_metadata_track.mp4.dump | 2 + ...65_with_metadata_track.mp4_fragmented.dump | 2 + .../assets/muxerdumps/hdr10-720p.mp4.dump | 2 + .../muxerdumps/hdr10-720p.mp4_fragmented.dump | 2 + .../muxerdumps/partial_hdr10-720p.mp4.dump | 2 + ...amable_output_disabled_hdr10-720p.mp4.dump | 2 + ...mple_batching_disabled_hdr10-720p.mp4.dump | 2 + .../muxerdumps/sample_edit_list.mp4.dump | 4 ++ .../sample_edit_list.mp4_fragmented.dump | 4 ++ .../transmuxed_with_inappmuxer.dump | 2 + .../transmuxed_with_inappmuxer.dump | 2 + .../media3/test/utils/DumpableFormat.java | 2 + 97 files changed, 368 insertions(+), 10 deletions(-) diff --git a/demos/main/src/main/assets/media.exolist.json b/demos/main/src/main/assets/media.exolist.json index 5351c6f8b2..fd9ea62324 100644 --- a/demos/main/src/main/assets/media.exolist.json +++ b/demos/main/src/main/assets/media.exolist.json @@ -618,6 +618,17 @@ "image_duration_ms": 2000 } ] + }, + { + "name": "Change in crop b/409036359", + "playlist": [ + { + "uri": "https://storage.googleapis.com/exoplayer-test-media-1/mp4/bbb_760x480_1mbps_60fps_hevc.mp4" + }, + { + "uri": "https://storage.googleapis.com/exoplayer-test-media-1/mp4/bbb_760x480_1mbps_60fps_hevc_pad.mp4" + } + ] } ] }, diff --git a/libraries/common/src/main/java/androidx/media3/common/Format.java b/libraries/common/src/main/java/androidx/media3/common/Format.java index 25a490d209..32da706cec 100644 --- a/libraries/common/src/main/java/androidx/media3/common/Format.java +++ b/libraries/common/src/main/java/androidx/media3/common/Format.java @@ -97,6 +97,8 @@ import java.util.UUID; *