From a49ce59d056e09e7abdbba57f9d43ca66f56d8ee Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Wed, 24 Apr 2024 12:42:38 +0100 Subject: [PATCH] Add a test case which has sample with rai set and dai unset --- .../media3/extractor/ts/MpeghReader.java | 6 +- .../media3/extractor/ts/TsExtractorTest.java | 9 ++ ...gh_bl_cicp1_cont_setrai_unsetdai.ts.0.dump | 133 ++++++++++++++++++ ...gh_bl_cicp1_cont_setrai_unsetdai.ts.1.dump | 17 +++ ...gh_bl_cicp1_cont_setrai_unsetdai.ts.2.dump | 17 +++ ...gh_bl_cicp1_cont_setrai_unsetdai.ts.3.dump | 17 +++ ...ont_setrai_unsetdai.ts.unknown_length.dump | 130 +++++++++++++++++ ...ple_mpegh_bl_cicp1_cont_setrai_unsetdai.ts | Bin 0 -> 74636 bytes 8 files changed, 327 insertions(+), 2 deletions(-) create mode 100644 libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.0.dump create mode 100644 libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.1.dump create mode 100644 libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.2.dump create mode 100644 libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.3.dump create mode 100644 libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.unknown_length.dump create mode 100644 libraries/test_data/src/test/assets/media/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/ts/MpeghReader.java b/libraries/extractor/src/main/java/androidx/media3/extractor/ts/MpeghReader.java index 53844a357f..7d85456d57 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/ts/MpeghReader.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/ts/MpeghReader.java @@ -55,6 +55,7 @@ public final class MpeghReader implements ElementaryStreamReader { private static final int STATE_READING_PACKET_HEADER = 1; private static final int STATE_READING_PACKET_PAYLOAD = 2; + private static final int MHAS_SYNC_WORD_LENGTH = 3; private static final int MAX_MHAS_PACKET_HEADER_SIZE = 15; private @State int state; @@ -224,8 +225,8 @@ public final class MpeghReader implements ElementaryStreamReader { } /** - * Locates the next SYNC value in the buffer, advancing the position to the byte that immediately - * follows it. If SYNC was not located, the position is advanced to the limit. + * Locates the next SYNC value in the buffer, advancing the position to the byte starting with the + * SYNC value. If SYNC was not located, the position is advanced to the limit. * * @param pesBuffer The buffer whose position should be advanced. * @return Whether SYNC was found. @@ -243,6 +244,7 @@ public final class MpeghReader implements ElementaryStreamReader { syncBytes <<= C.BITS_PER_BYTE; syncBytes |= pesBuffer.readUnsignedByte(); if (MpeghUtil.isSyncWord(syncBytes)) { + pesBuffer.setPosition(pesBuffer.getPosition() - MHAS_SYNC_WORD_LENGTH); syncBytes = 0; return true; } diff --git a/libraries/extractor/src/test/java/androidx/media3/extractor/ts/TsExtractorTest.java b/libraries/extractor/src/test/java/androidx/media3/extractor/ts/TsExtractorTest.java index 192d4e733f..2ae06cdbca 100644 --- a/libraries/extractor/src/test/java/androidx/media3/extractor/ts/TsExtractorTest.java +++ b/libraries/extractor/src/test/java/androidx/media3/extractor/ts/TsExtractorTest.java @@ -342,6 +342,15 @@ public final class TsExtractorTest { simulationConfig); } + @Test + public void sampleWithMpeghBlContSetRaiUnsetDai() throws Exception { + ExtractorAsserts.assertBehavior( + getExtractorFactory(subtitlesParsedDuringExtraction), + "media/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts", + simulationConfig); + } + + @Test public void customPesReader() throws Exception { CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false); diff --git a/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.0.dump b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.0.dump new file mode 100644 index 0000000000..039faf8cff --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.0.dump @@ -0,0 +1,133 @@ +seekMap: + isSeekable = true + duration = 567011 + getPosition(0) = [[timeUs=0, position=0]] + getPosition(1) = [[timeUs=1, position=0]] + getPosition(283505) = [[timeUs=283505, position=35264]] + getPosition(567011) = [[timeUs=567011, position=70716]] +numberOfTracks = 1 +track 32: + total output bytes = 2717 + sample count = 29 + format 0: + id = 1/32 + sampleMimeType = audio/mhm1 + codecs = mhm1.10 + sampleRate = 48000 + sample 0: + time = 0 + flags = 1 + data = length 337, hash 84E728C1 + sample 1: + time = 21333 + flags = 0 + data = length 89, hash 64104580 + sample 2: + time = 42666 + flags = 0 + data = length 102, hash 845EBE43 + sample 3: + time = 64000 + flags = 0 + data = length 110, hash 38545FDF + sample 4: + time = 85333 + flags = 0 + data = length 101, hash D3216774 + sample 5: + time = 106666 + flags = 0 + data = length 96, hash E5096A84 + sample 6: + time = 127999 + flags = 0 + data = length 95, hash 514E63BF + sample 7: + time = 149333 + flags = 0 + data = length 90, hash F45706D3 + sample 8: + time = 170666 + flags = 0 + data = length 89, hash B219E93F + sample 9: + time = 191999 + flags = 0 + data = length 89, hash 9D90394 + sample 10: + time = 213333 + flags = 0 + data = length 81, hash 9D7A1584 + sample 11: + time = 234666 + flags = 0 + data = length 83, hash 6E0457B0 + sample 12: + time = 256000 + flags = 0 + data = length 82, hash 5972B44D + sample 13: + time = 277333 + flags = 0 + data = length 82, hash 6639E113 + sample 14: + time = 298667 + flags = 0 + data = length 80, hash B550B518 + sample 15: + time = 320000 + flags = 0 + data = length 82, hash 73F61B02 + sample 16: + time = 341333 + flags = 0 + data = length 81, hash CA4029EB + sample 17: + time = 362666 + flags = 0 + data = length 78, hash 6C216053 + sample 18: + time = 383999 + flags = 0 + data = length 79, hash 25933965 + sample 19: + time = 405333 + flags = 0 + data = length 81, hash 5057B59B + sample 20: + time = 426666 + flags = 0 + data = length 77, hash 1209F544 + sample 21: + time = 447999 + flags = 0 + data = length 79, hash 8F79706F + sample 22: + time = 469333 + flags = 0 + data = length 81, hash 5057B592 + sample 23: + time = 490666 + flags = 0 + data = length 77, hash 1209F545 + sample 24: + time = 512000 + flags = 0 + data = length 79, hash 8F79705D + sample 25: + time = 533333 + flags = 0 + data = length 81, hash D05E7A84 + sample 26: + time = 554666 + flags = 0 + data = length 76, hash 7C69C79 + sample 27: + time = 576000 + flags = 0 + data = length 85, hash 968BAF7A + sample 28: + time = 597333 + flags = 0 + data = length 75, hash 69A79E91 +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.1.dump b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.1.dump new file mode 100644 index 0000000000..27c35eb1c2 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.1.dump @@ -0,0 +1,17 @@ +seekMap: + isSeekable = true + duration = 567011 + getPosition(0) = [[timeUs=0, position=0]] + getPosition(1) = [[timeUs=1, position=0]] + getPosition(283505) = [[timeUs=283505, position=35264]] + getPosition(567011) = [[timeUs=567011, position=70716]] +numberOfTracks = 1 +track 32: + total output bytes = 0 + sample count = 0 + format 0: + id = 1/32 + sampleMimeType = audio/mhm1 + codecs = mhm1.10 + sampleRate = 48000 +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.2.dump b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.2.dump new file mode 100644 index 0000000000..27c35eb1c2 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.2.dump @@ -0,0 +1,17 @@ +seekMap: + isSeekable = true + duration = 567011 + getPosition(0) = [[timeUs=0, position=0]] + getPosition(1) = [[timeUs=1, position=0]] + getPosition(283505) = [[timeUs=283505, position=35264]] + getPosition(567011) = [[timeUs=567011, position=70716]] +numberOfTracks = 1 +track 32: + total output bytes = 0 + sample count = 0 + format 0: + id = 1/32 + sampleMimeType = audio/mhm1 + codecs = mhm1.10 + sampleRate = 48000 +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.3.dump b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.3.dump new file mode 100644 index 0000000000..27c35eb1c2 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.3.dump @@ -0,0 +1,17 @@ +seekMap: + isSeekable = true + duration = 567011 + getPosition(0) = [[timeUs=0, position=0]] + getPosition(1) = [[timeUs=1, position=0]] + getPosition(283505) = [[timeUs=283505, position=35264]] + getPosition(567011) = [[timeUs=567011, position=70716]] +numberOfTracks = 1 +track 32: + total output bytes = 0 + sample count = 0 + format 0: + id = 1/32 + sampleMimeType = audio/mhm1 + codecs = mhm1.10 + sampleRate = 48000 +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.unknown_length.dump b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.unknown_length.dump new file mode 100644 index 0000000000..5b9588c73f --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts.unknown_length.dump @@ -0,0 +1,130 @@ +seekMap: + isSeekable = false + duration = UNSET TIME + getPosition(0) = [[timeUs=0, position=0]] +numberOfTracks = 1 +track 32: + total output bytes = 2717 + sample count = 29 + format 0: + id = 1/32 + sampleMimeType = audio/mhm1 + codecs = mhm1.10 + sampleRate = 48000 + sample 0: + time = 0 + flags = 1 + data = length 337, hash 84E728C1 + sample 1: + time = 21333 + flags = 0 + data = length 89, hash 64104580 + sample 2: + time = 42666 + flags = 0 + data = length 102, hash 845EBE43 + sample 3: + time = 64000 + flags = 0 + data = length 110, hash 38545FDF + sample 4: + time = 85333 + flags = 0 + data = length 101, hash D3216774 + sample 5: + time = 106666 + flags = 0 + data = length 96, hash E5096A84 + sample 6: + time = 127999 + flags = 0 + data = length 95, hash 514E63BF + sample 7: + time = 149333 + flags = 0 + data = length 90, hash F45706D3 + sample 8: + time = 170666 + flags = 0 + data = length 89, hash B219E93F + sample 9: + time = 191999 + flags = 0 + data = length 89, hash 9D90394 + sample 10: + time = 213333 + flags = 0 + data = length 81, hash 9D7A1584 + sample 11: + time = 234666 + flags = 0 + data = length 83, hash 6E0457B0 + sample 12: + time = 256000 + flags = 0 + data = length 82, hash 5972B44D + sample 13: + time = 277333 + flags = 0 + data = length 82, hash 6639E113 + sample 14: + time = 298667 + flags = 0 + data = length 80, hash B550B518 + sample 15: + time = 320000 + flags = 0 + data = length 82, hash 73F61B02 + sample 16: + time = 341333 + flags = 0 + data = length 81, hash CA4029EB + sample 17: + time = 362666 + flags = 0 + data = length 78, hash 6C216053 + sample 18: + time = 383999 + flags = 0 + data = length 79, hash 25933965 + sample 19: + time = 405333 + flags = 0 + data = length 81, hash 5057B59B + sample 20: + time = 426666 + flags = 0 + data = length 77, hash 1209F544 + sample 21: + time = 447999 + flags = 0 + data = length 79, hash 8F79706F + sample 22: + time = 469333 + flags = 0 + data = length 81, hash 5057B592 + sample 23: + time = 490666 + flags = 0 + data = length 77, hash 1209F545 + sample 24: + time = 512000 + flags = 0 + data = length 79, hash 8F79705D + sample 25: + time = 533333 + flags = 0 + data = length 81, hash D05E7A84 + sample 26: + time = 554666 + flags = 0 + data = length 76, hash 7C69C79 + sample 27: + time = 576000 + flags = 0 + data = length 85, hash 968BAF7A + sample 28: + time = 597333 + flags = 0 + data = length 75, hash 69A79E91 +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/media/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts b/libraries/test_data/src/test/assets/media/ts/sample_mpegh_bl_cicp1_cont_setrai_unsetdai.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d8f94c94ffe00a99901a726680b2ee8acb6e825 GIT binary patch literal 74636 zcmeI52~-qU*2iD72qIz=$OwYc3K0TC8k&7=m8C&2HrOiqvH3v@QG$aQ{SpI>E1FTj zh_O+YaYI_%LZT#q!MG%1yChM>F{6lET!<)=!Hu4(Hj~Ji$vItBZ}@oU+&aho{r}zm z`c}QJd+&P{Ax6TjNHfq6g!Y>w-ZzLk+W3ffgJ&-KG%-TV7p@v0?;VLdU3usm9Dy#H#Tc0=3{p;^^eBZw!AI0Tc_t$vLLP@i1nvtuST2Mg|DXmcLw!VJ!X_atda*0b|+mTIsmJc&b2rydneDKeI4XX(q(&d|0yE)Q4 z^=~rl@Y}ZsT zOR--Ke)8dGzVXEFM14jmxBi8P5xJEw5^VbU|V=VKLW zwfdO)7r8u5Mjde`l6lnsy~V9Ai0GJsd6nrU0?T-a87vqXn*evl$gl{2I~I(LO@KRN zWLN~i9ScUrCcvFBGAsh%js+uQ6Qa2zfx{u{e%1Izu4I7R@ag zY`a&^{9lAgb#6)Z5sja;Jhb^*l6Zb+jj*m@O-yd5z5Kw0oef1xDpPBYM&BPk`V*4;FJ0#q)loHWpVqu}Up}gzVwpbihNfk_K5t32mx;x? z_FXg6zldwSxnWoLtjOf#bvIqTm%ed)VRNQ=0#(=cE<`$~75Zi1$`#fLPgb^G30T=R z+0yDbKk0#K&1v;Pm0UirS=CJamtP($h`zo=C5iM`JRc{jKT`hwh!@YhcYOBw8vS0xyL;#6 zhk}u4$_-n?(dO1`Hy(Ah`f>W)gNLlk>(;-2f5!yr;4JaqCT&Z&Ju{>I*GBf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