Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5f76e0fa
authored
Jan 31, 2022
by
Dustin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
AvcChunkPeeker tests
parent
d006f3f4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
1 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AvcChunkPeeker.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/PicCountClock.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AvcChunkPeekerTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviTrackTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/BitBuffer.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AvcChunkPeeker.java
View file @
5f76e0fa
...
...
@@ -34,7 +34,7 @@ public class AvcChunkPeeker extends NalChunkPeeker {
picCountClock
=
new
PicCountClock
(
clock
.
durationUs
,
clock
.
length
);
}
public
Linear
Clock
getClock
()
{
public
PicCount
Clock
getClock
()
{
return
picCountClock
;
}
...
...
@@ -131,4 +131,9 @@ public class AvcChunkPeeker extends NalChunkPeeker {
compact
();
}
}
@VisibleForTesting
(
otherwise
=
VisibleForTesting
.
NONE
)
public
NalUnitUtil
.
SpsData
getSpsData
()
{
return
spsData
;
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/PicCountClock.java
View file @
5f76e0fa
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
androidx.annotation.VisibleForTesting
;
/**
* Properly calculates the frame time for H264 frames using PicCount
*/
...
...
@@ -60,4 +62,14 @@ public class PicCountClock extends LinearClock {
public
long
getUs
()
{
return
getUs
(
picIndex
);
}
@VisibleForTesting
(
otherwise
=
VisibleForTesting
.
NONE
)
int
getMaxPicCount
()
{
return
maxPicCount
;
}
@VisibleForTesting
(
otherwise
=
VisibleForTesting
.
NONE
)
int
getLastPicCount
()
{
return
lastPicCount
;
}
}
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AvcChunkPeekerTest.java
0 → 100644
View file @
5f76e0fa
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
android.content.Context
;
import
androidx.test.core.app.ApplicationProvider
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.testutil.FakeExtractorInput
;
import
com.google.android.exoplayer2.testutil.FakeTrackOutput
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.io.IOException
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
AvcChunkPeekerTest
{
private
static
final
Format
.
Builder
FORMAT_BUILDER_AVC
=
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
).
setWidth
(
1280
).
setHeight
(
720
).
setFrameRate
(
24000
f
/
1001
f
);
private
static
final
byte
[]
P_SLICE
=
{
00
,
00
,
00
,
01
,
0x41
,(
byte
)
0x9A
,
0x13
,
0x36
,
0x21
,
0x3A
,
0x5F
,
(
byte
)
0xFE
,(
byte
)
0x9E
,
0x10
,
00
,
00
};
private
FakeTrackOutput
fakeTrackOutput
;
private
AvcChunkPeeker
avcChunkPeeker
;
@Before
public
void
before
()
{
fakeTrackOutput
=
new
FakeTrackOutput
(
false
);
avcChunkPeeker
=
new
AvcChunkPeeker
(
FORMAT_BUILDER_AVC
,
fakeTrackOutput
,
new
LinearClock
(
10_000_000L
,
24
*
10
));
}
private
void
peekStreamHeader
()
throws
IOException
{
final
Context
context
=
ApplicationProvider
.
getApplicationContext
();
final
byte
[]
bytes
=
TestUtil
.
getByteArray
(
context
,
"extractordumps/avi/avc_sei_sps_pps_ird.dump"
);
final
FakeExtractorInput
input
=
new
FakeExtractorInput
.
Builder
().
setData
(
bytes
).
build
();
avcChunkPeeker
.
peek
(
input
,
bytes
.
length
);
}
@Test
public
void
peek_givenStreamHeader
()
throws
IOException
{
peekStreamHeader
();
final
PicCountClock
picCountClock
=
avcChunkPeeker
.
getClock
();
Assert
.
assertEquals
(
64
,
picCountClock
.
getMaxPicCount
());
Assert
.
assertEquals
(
0
,
avcChunkPeeker
.
getSpsData
().
picOrderCountType
);
Assert
.
assertEquals
(
1.18f
,
fakeTrackOutput
.
lastFormat
.
pixelWidthHeightRatio
,
0.01f
);
}
@Test
public
void
peek_givenStreamHeaderAndPSlice
()
throws
IOException
{
peekStreamHeader
();
final
PicCountClock
picCountClock
=
avcChunkPeeker
.
getClock
();
final
FakeExtractorInput
input
=
new
FakeExtractorInput
.
Builder
().
setData
(
P_SLICE
).
build
();
avcChunkPeeker
.
peek
(
input
,
P_SLICE
.
length
);
Assert
.
assertEquals
(
12
,
picCountClock
.
getLastPicCount
());
}
}
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviTrackTest.java
0 → 100644
View file @
5f76e0fa
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
org.junit.Assert
;
import
org.junit.Test
;
public
class
AviTrackTest
{
@Test
public
void
setClock_givenLinearClock
()
{
final
LinearClock
linearClock
=
new
LinearClock
(
1_000_000L
,
30
);
final
AviTrack
aviTrack
=
DataHelper
.
getVideoAviTrack
(
1
);
aviTrack
.
setClock
(
linearClock
);
Assert
.
assertSame
(
linearClock
,
aviTrack
.
getClock
());
}
}
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/BitBuffer.java
View file @
5f76e0fa
...
...
@@ -30,6 +30,19 @@ public class BitBuffer {
work
|=
(
value
&
0xffffffff
L
);
}
public
void
pushExpGolomb
(
final
int
i
)
{
if
(
i
==
0
)
{
push
(
true
);
}
int
v
=
i
+
1
;
int
zeroBits
=
0
;
while
((
v
>>>=
1
)
>
1
)
{
zeroBits
++;
}
final
int
bits
=
zeroBits
*
2
+
1
;
push
(
bits
,
i
+
1
);
}
public
byte
[]
getBytes
()
{
//Byte align
grow
(
8
-
bits
%
8
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment