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
a9c94185
authored
Jan 17, 2022
by
Dustin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Working!
parent
33d22a12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
320 additions
and
68 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AudioFormat.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviHeader.java → library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviHeaderBox.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviTrack.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviUtil.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/Box.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/BoxFactory.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/IAviList.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ResidentList.java → library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ListBox.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ResidentBox.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamFormat.java → library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamFormatBox.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamHeader.java → library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamHeaderBox.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/UnboundedIntArray.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AudioFormat.java
View file @
a9c94185
...
...
@@ -5,14 +5,16 @@ import com.google.android.exoplayer2.util.MimeTypes;
import
java.nio.ByteBuffer
;
public
class
AudioFormat
{
public
static
short
WAVE_FORMAT_PCM
=
1
;
public
static
short
WAVE_FORMAT_MPEGLAYER3
=
0x55
;
public
static
short
WAVE_FORMAT_DVM
=
0x2000
;
//AC3
public
static
short
WAVE_FORMAT_DTS2
=
0x2001
;
//DTS
public
static
final
short
WAVE_FORMAT_PCM
=
1
;
private
static
final
short
WAVE_FORMAT_MPEGLAYER3
=
0x55
;
private
static
final
short
WAVE_FORMAT_AAC
=
0xff
;
private
static
final
short
WAVE_FORMAT_DVM
=
0x2000
;
//AC3
private
static
final
short
WAVE_FORMAT_DTS2
=
0x2001
;
//DTS
private
static
final
SparseArray
<
String
>
FORMAT_MAP
=
new
SparseArray
<>();
static
{
FORMAT_MAP
.
put
(
WAVE_FORMAT_PCM
,
MimeTypes
.
AUDIO_RAW
);
FORMAT_MAP
.
put
(
WAVE_FORMAT_MPEGLAYER3
,
MimeTypes
.
AUDIO_MPEG
);
FORMAT_MAP
.
put
(
WAVE_FORMAT_AAC
,
MimeTypes
.
AUDIO_AAC
);
FORMAT_MAP
.
put
(
WAVE_FORMAT_DVM
,
MimeTypes
.
AUDIO_AC3
);
FORMAT_MAP
.
put
(
WAVE_FORMAT_DTS2
,
MimeTypes
.
AUDIO_DTS
);
}
...
...
@@ -24,7 +26,7 @@ public class AudioFormat {
this
.
byteBuffer
=
byteBuffer
;
}
public
String
get
Codec
()
{
public
String
get
MimeType
()
{
return
FORMAT_MAP
.
get
(
getFormatTag
()
&
0xffff
);
}
...
...
@@ -38,12 +40,24 @@ public class AudioFormat {
return
byteBuffer
.
getInt
(
4
);
}
// 8 - nAvgBytesPerSec(uint)
// 12 - nBlockAlign(ushort)
public
int
getBlockAlign
()
{
return
byteBuffer
.
getShort
(
12
);
}
public
short
getBitsPerSample
()
{
return
byteBuffer
.
getShort
(
14
);
}
public
short
getCbSize
()
{
return
byteBuffer
.
getShort
(
16
);
public
int
getCbSize
()
{
return
byteBuffer
.
getShort
(
16
)
&
0xffff
;
}
public
byte
[]
getCodecData
()
{
final
int
size
=
getCbSize
();
final
ByteBuffer
temp
=
byteBuffer
.
duplicate
();
temp
.
clear
();
temp
.
position
(
18
);
temp
.
limit
(
18
+
size
);
final
byte
[]
data
=
new
byte
[
size
];
temp
.
get
(
data
);
return
data
;
}
//TODO: Deal with WAVEFORMATEXTENSIBLE
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java
View file @
a9c94185
This diff is collapsed.
Click to expand it.
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviHeader.java
→
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviHeader
Box
.java
View file @
a9c94185
...
...
@@ -2,13 +2,13 @@ package com.google.android.exoplayer2.extractor.avi;
import
java.nio.ByteBuffer
;
public
class
AviHeader
extends
ResidentBox
{
public
class
AviHeader
Box
extends
ResidentBox
{
public
static
final
int
AVIF_HASINDEX
=
0x10
;
static
final
int
AVIH
=
'a'
|
(
'v'
<<
8
)
|
(
'i'
<<
16
)
|
(
'h'
<<
24
);
//AVIMAINHEADER
AviHeader
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
AviHeader
Box
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
super
(
type
,
size
,
byteBuffer
);
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java
0 → 100644
View file @
a9c94185
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
android.util.SparseArray
;
import
androidx.annotation.NonNull
;
import
com.google.android.exoplayer2.extractor.SeekMap
;
import
com.google.android.exoplayer2.extractor.SeekPoint
;
import
com.google.android.exoplayer2.util.Log
;
public
class
AviSeekMap
implements
SeekMap
{
final
AviTrack
videoTrack
;
/**
* Number of frames per index
* i.e. videoFrameOffsetMap[1] is frame 1 * seekIndexFactor
*/
final
int
seekIndexFactor
;
//Map from the Video Frame index to the offset
final
int
[]
videoFrameOffsetMap
;
//Holds a map of video frameIds to audioFrameIds for each audioId
final
SparseArray
<
int
[]>
audioIdMap
;
final
long
moviOffset
;
final
long
duration
;
public
AviSeekMap
(
AviTrack
videoTrack
,
int
seekIndexFactor
,
int
[]
videoFrameOffsetMap
,
SparseArray
<
int
[]>
audioIdMap
,
long
moviOffset
,
long
duration
)
{
this
.
videoTrack
=
videoTrack
;
this
.
seekIndexFactor
=
seekIndexFactor
;
this
.
videoFrameOffsetMap
=
videoFrameOffsetMap
;
this
.
audioIdMap
=
audioIdMap
;
this
.
moviOffset
=
moviOffset
;
this
.
duration
=
duration
;
}
@Override
public
boolean
isSeekable
()
{
return
true
;
}
@Override
public
long
getDurationUs
()
{
return
duration
;
}
private
int
getSeekFrameIndex
(
long
timeUs
)
{
final
int
reqFrame
=
(
int
)(
timeUs
/
videoTrack
.
usPerSample
);
int
reqFrameIndex
=
reqFrame
/
seekIndexFactor
;
if
(
reqFrameIndex
>=
videoFrameOffsetMap
.
length
)
{
reqFrameIndex
=
videoFrameOffsetMap
.
length
-
1
;
}
return
reqFrameIndex
;
}
@NonNull
@Override
public
SeekPoints
getSeekPoints
(
long
timeUs
)
{
final
int
seekFrameIndex
=
getSeekFrameIndex
(
timeUs
);
int
offset
=
videoFrameOffsetMap
[
seekFrameIndex
];
final
long
outUs
=
seekFrameIndex
*
seekIndexFactor
*
videoTrack
.
usPerSample
;
final
long
position
=
offset
+
moviOffset
;
Log
.
d
(
AviExtractor
.
TAG
,
"SeekPoint: us="
+
outUs
+
" pos="
+
position
);
return
new
SeekPoints
(
new
SeekPoint
(
outUs
,
position
));
}
public
void
setFrames
(
final
long
position
,
final
long
timeUs
,
final
SparseArray
<
AviTrack
>
idTrackMap
)
{
final
int
seekFrameIndex
=
getSeekFrameIndex
(
timeUs
);
videoTrack
.
frame
=
seekFrameIndex
*
seekIndexFactor
;
for
(
int
i
=
0
;
i
<
audioIdMap
.
size
();
i
++)
{
final
int
audioId
=
audioIdMap
.
keyAt
(
i
);
final
int
[]
video2AudioFrameMap
=
audioIdMap
.
get
(
audioId
);
final
AviTrack
audioTrack
=
idTrackMap
.
get
(
audioId
);
audioTrack
.
frame
=
video2AudioFrameMap
[
seekFrameIndex
];
}
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviTrack.java
0 → 100644
View file @
a9c94185
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
android.util.SparseIntArray
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.extractor.TrackOutput
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.util.Arrays
;
/**
* Collection of info about a track
*/
public
class
AviTrack
{
final
int
id
;
@NonNull
final
TrackOutput
trackOutput
;
@NonNull
final
StreamHeaderBox
streamHeaderBox
;
long
usPerSample
;
/**
* True indicates all frames are key frames (e.g. Audio, MJPEG)
*/
boolean
allKeyFrames
;
/**
* Key is frame number value is offset
*/
@Nullable
int
[]
keyFrames
;
/**
* Current frame in the stream
* This needs to be updated on seek
* TODO: Should be offset from StreamHeaderBox.getStart()
*/
transient
int
frame
;
/**
*
* @param trackOutput
*/
AviTrack
(
int
id
,
@NonNull
TrackOutput
trackOutput
,
@NonNull
StreamHeaderBox
streamHeaderBox
)
{
this
.
id
=
id
;
this
.
trackOutput
=
trackOutput
;
this
.
streamHeaderBox
=
streamHeaderBox
;
this
.
usPerSample
=
streamHeaderBox
.
getUsPerSample
();
this
.
allKeyFrames
=
streamHeaderBox
.
isAudio
()
||
(
MimeTypes
.
IMAGE_JPEG
.
equals
(
streamHeaderBox
.
getMimeType
()));
}
public
boolean
isKeyFrame
()
{
if
(
allKeyFrames
)
{
return
true
;
}
return
keyFrames
!=
null
&&
Arrays
.
binarySearch
(
keyFrames
,
frame
)
>=
0
;
}
public
void
setKeyFrames
(
int
[]
keyFrames
)
{
this
.
keyFrames
=
keyFrames
;
}
public
long
getUs
()
{
return
frame
*
usPerSample
;
}
public
void
advance
()
{
frame
++;
}
public
boolean
isVideo
()
{
return
streamHeaderBox
.
isVideo
();
}
public
boolean
isAudio
()
{
return
streamHeaderBox
.
isAudio
();
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviUtil.java
View file @
a9c94185
...
...
@@ -65,17 +65,4 @@ public class AviUtil {
}
return
null
;
}
@Nullable
static
IAviList
getSubList
(
List
<?
extends
Box
>
list
,
int
listType
)
{
for
(
Box
box
:
list
)
{
if
(
IAviList
.
class
.
isInstance
(
box
))
{
final
IAviList
aviList
=
(
IAviList
)
box
;
if
(
aviList
.
getListType
()
==
listType
)
{
return
aviList
;
}
}
}
return
null
;
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/Box.java
View file @
a9c94185
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
/**
* This is referred to as a Chunk in the MS spec, but that gets confusing with AV chunks
*/
public
class
Box
{
private
final
long
size
;
private
final
int
type
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/BoxFactory.java
0 → 100644
View file @
a9c94185
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
androidx.annotation.NonNull
;
import
java.nio.ByteBuffer
;
public
class
BoxFactory
{
@NonNull
public
ResidentBox
createBox
(
final
int
type
,
final
int
size
,
final
ByteBuffer
byteBuffer
)
{
final
ByteBuffer
boxBuffer
=
AviExtractor
.
allocate
(
size
);
AviUtil
.
copy
(
byteBuffer
,
boxBuffer
,
size
);
switch
(
type
)
{
case
AviHeaderBox
.
AVIH
:
return
new
AviHeaderBox
(
type
,
size
,
boxBuffer
);
case
ListBox
.
LIST
:
return
new
ListBox
(
type
,
size
,
boxBuffer
);
case
StreamHeaderBox
.
STRH
:
return
new
StreamHeaderBox
(
type
,
size
,
boxBuffer
);
case
StreamFormatBox
.
STRF
:
return
new
StreamFormatBox
(
type
,
size
,
boxBuffer
);
default
:
return
new
ResidentBox
(
type
,
size
,
boxBuffer
);
}
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/IAviList.java
deleted
100644 → 0
View file @
33d22a12
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
public
interface
IAviList
{
int
LIST
=
'L'
|
(
'I'
<<
8
)
|
(
'S'
<<
16
)
|
(
'T'
<<
24
);
//Header List
int
TYPE_HDRL
=
'h'
|
(
'd'
<<
8
)
|
(
'r'
<<
16
)
|
(
'l'
<<
24
);
int
getListType
();
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/
ResidentList
.java
→
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/
ListBox
.java
View file @
a9c94185
...
...
@@ -5,15 +5,18 @@ import java.nio.ByteBuffer;
/**
* An AVI LIST box, memory resident
*/
public
class
ResidentList
extends
ResidentBox
implements
IAviList
{
public
class
ListBox
extends
ResidentBox
{
public
static
final
int
LIST
=
'L'
|
(
'I'
<<
8
)
|
(
'S'
<<
16
)
|
(
'T'
<<
24
);
//Header List
public
static
final
int
TYPE_HDRL
=
'h'
|
(
'd'
<<
8
)
|
(
'r'
<<
16
)
|
(
'l'
<<
24
);
private
final
int
listType
;
ResidentList
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
ListBox
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
super
(
type
,
size
,
byteBuffer
);
listType
=
byteBuffer
.
getInt
(
0
);
}
@Override
public
int
getListType
()
{
return
listType
;
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ResidentBox.java
View file @
a9c94185
...
...
@@ -13,25 +13,28 @@ import java.nio.ByteOrder;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* A box that is resident in memory
*/
public
class
ResidentBox
extends
Box
{
private
static
final
String
TAG
=
AviExtractor
.
TAG
;
final
private
static
int
MAX_RESIDENT
=
2
*
1024
;
final
private
static
int
MAX_RESIDENT
=
64
*
1024
;
final
ByteBuffer
byteBuffer
;
private
Class
<?
extends
ResidentBox
>
getClass
(
final
int
type
)
{
switch
(
type
)
{
case
AviHeader
.
AVIH
:
return
AviHeader
.
class
;
case
IAviList
.
LIST
:
return
ResidentList
.
class
;
case
StreamHeader
.
STRH
:
return
StreamHeader
.
class
;
case
StreamFormat
.
STRF
:
return
StreamFormat
.
class
;
default
:
return
ResidentBox
.
class
;
}
}
//
private Class<? extends ResidentBox> getClass(final int type) {
//
switch (type) {
// case AviHeaderBox
.AVIH:
// return AviHeaderBox
.class;
// case ListBox
.LIST:
// return ListBox
.class;
// case StreamHeaderBox
.STRH:
// return StreamHeaderBox
.class;
// case StreamFormatBox
.STRF:
// return StreamFormatBox
.class;
//
default:
//
return ResidentBox.class;
//
}
//
}
ResidentBox
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
super
(
type
,
size
);
...
...
@@ -92,20 +95,14 @@ public class ResidentBox extends Box {
}
@NonNull
public
List
<
ResidentBox
>
getBoxList
()
{
public
List
<
ResidentBox
>
getBoxList
(
final
BoxFactory
boxFactory
)
{
final
ByteBuffer
temp
=
getByteBuffer
();
temp
.
position
(
4
);
final
List
<
ResidentBox
>
list
=
new
ArrayList
<>();
while
(
temp
.
hasRemaining
())
{
final
int
type
=
temp
.
getInt
();
final
int
size
=
temp
.
getInt
();
final
Class
<?
extends
ResidentBox
>
clazz
=
getClass
(
type
);
final
ByteBuffer
boxBuffer
=
AviExtractor
.
allocate
(
size
);
AviUtil
.
copy
(
temp
,
boxBuffer
,
size
);
final
ResidentBox
residentBox
=
newInstance
(
type
,
size
,
boxBuffer
,
clazz
);
if
(
residentBox
==
null
)
{
break
;
}
final
ResidentBox
residentBox
=
boxFactory
.
createBox
(
type
,
size
,
temp
);
list
.
add
(
residentBox
);
}
return
list
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamFormat.java
→
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamFormat
Box
.java
View file @
a9c94185
...
...
@@ -3,10 +3,10 @@ package com.google.android.exoplayer2.extractor.avi;
import
androidx.annotation.NonNull
;
import
java.nio.ByteBuffer
;
public
class
StreamFormat
extends
ResidentBox
{
public
class
StreamFormat
Box
extends
ResidentBox
{
public
static
final
int
STRF
=
's'
|
(
't'
<<
8
)
|
(
'r'
<<
16
)
|
(
'f'
<<
24
);
StreamFormat
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
StreamFormat
Box
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
super
(
type
,
size
,
byteBuffer
);
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamHeader.java
→
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/StreamHeader
Box
.java
View file @
a9c94185
...
...
@@ -4,7 +4,10 @@ import android.util.SparseArray;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.nio.ByteBuffer
;
public
class
StreamHeader
extends
ResidentBox
{
/**
* AVISTREAMHEADER
*/
public
class
StreamHeaderBox
extends
ResidentBox
{
public
static
final
int
STRH
=
's'
|
(
't'
<<
8
)
|
(
'r'
<<
16
)
|
(
'h'
<<
24
);
//Audio Stream
...
...
@@ -16,15 +19,23 @@ public class StreamHeader extends ResidentBox {
private
static
final
SparseArray
<
String
>
STREAM_MAP
=
new
SparseArray
<>();
static
{
STREAM_MAP
.
put
(
'M'
|
(
'P'
<<
8
)
|
(
'4'
<<
16
)
|
(
'2'
<<
24
),
MimeTypes
.
VIDEO_MP4V
);
STREAM_MAP
.
put
(
'3'
|
(
'V'
<<
8
)
|
(
'I'
<<
16
)
|
(
'D'
<<
24
),
MimeTypes
.
VIDEO_MP4V
);
STREAM_MAP
.
put
(
'x'
|
(
'v'
<<
8
)
|
(
'i'
<<
16
)
|
(
'd'
<<
24
),
MimeTypes
.
VIDEO_MP4V
);
STREAM_MAP
.
put
(
'X'
|
(
'V'
<<
8
)
|
(
'I'
<<
16
)
|
(
'D'
<<
24
),
MimeTypes
.
VIDEO_MP4V
);
//Although other types are technically supported, AVI is almost exclusively MP4V and MJPEG
final
String
mimeType
=
MimeTypes
.
VIDEO_MP4V
;
//final String mimeType = MimeTypes.VIDEO_H263;
//Doesn't seem to be supported on Android
//STREAM_MAP.put('M' | ('P' << 8) | ('4' << 16) | ('2' << 24), MimeTypes.VIDEO_MP4);
STREAM_MAP
.
put
(
'H'
|
(
'2'
<<
8
)
|
(
'6'
<<
16
)
|
(
'4'
<<
24
),
MimeTypes
.
VIDEO_H264
);
STREAM_MAP
.
put
(
'a'
|
(
'v'
<<
8
)
|
(
'c'
<<
16
)
|
(
'1'
<<
24
),
MimeTypes
.
VIDEO_H264
);
STREAM_MAP
.
put
(
'A'
|
(
'V'
<<
8
)
|
(
'C'
<<
16
)
|
(
'1'
<<
24
),
MimeTypes
.
VIDEO_H264
);
STREAM_MAP
.
put
(
'3'
|
(
'V'
<<
8
)
|
(
'I'
<<
16
)
|
(
'D'
<<
24
),
mimeType
);
STREAM_MAP
.
put
(
'x'
|
(
'v'
<<
8
)
|
(
'i'
<<
16
)
|
(
'd'
<<
24
),
mimeType
);
STREAM_MAP
.
put
(
'X'
|
(
'V'
<<
8
)
|
(
'I'
<<
16
)
|
(
'D'
<<
24
),
mimeType
);
STREAM_MAP
.
put
(
'm'
|
(
'j'
<<
8
)
|
(
'p'
<<
16
)
|
(
'g'
<<
24
),
MimeTypes
.
IMAGE_JPEG
);
}
StreamHeader
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
StreamHeader
Box
(
int
type
,
int
size
,
ByteBuffer
byteBuffer
)
{
super
(
type
,
size
,
byteBuffer
);
}
...
...
@@ -40,7 +51,15 @@ public class StreamHeader extends ResidentBox {
return
getRate
()
/
(
float
)
getScale
();
}
public
String
getCodec
()
{
/**
* How long each sample covers
* @return
*/
public
long
getUsPerSample
()
{
return
getScale
()
*
1_000_000L
/
getRate
();
}
public
String
getMimeType
()
{
return
STREAM_MAP
.
get
(
getFourCC
());
}
...
...
@@ -67,8 +86,15 @@ public class StreamHeader extends ResidentBox {
public
int
getRate
()
{
return
byteBuffer
.
getInt
(
24
);
}
//28 - dwStart
public
int
getStart
()
{
return
byteBuffer
.
getInt
(
28
);
}
public
long
getLength
()
{
return
byteBuffer
.
getInt
(
32
)
&
AviUtil
.
UINT_MASK
;
}
//36 - dwSuggestedBufferSize
//40 - dwQuality
public
int
getSampleSize
()
{
return
byteBuffer
.
getInt
(
44
);
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/UnboundedIntArray.java
0 → 100644
View file @
a9c94185
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
androidx.annotation.NonNull
;
import
java.util.Arrays
;
public
class
UnboundedIntArray
{
@NonNull
int
[]
array
;
//unint
int
size
=
0
;
public
UnboundedIntArray
()
{
this
(
8
);
}
public
UnboundedIntArray
(
int
size
)
{
if
(
size
<
0
)
{
throw
new
IllegalArgumentException
(
"Initial size must be positive: "
+
size
);
}
array
=
new
int
[
size
];
}
public
void
add
(
int
v
)
{
if
(
size
==
array
.
length
)
{
grow
();
}
array
[
size
++]
=
v
;
}
public
int
getSize
()
{
return
size
;
}
public
void
pack
()
{
array
=
Arrays
.
copyOf
(
array
,
size
);
}
protected
void
grow
()
{
int
increase
=
Math
.
max
(
array
.
length
/
4
,
1
);
array
=
Arrays
.
copyOf
(
array
,
increase
+
array
.
length
+
size
);
}
/**
* Only works if values are in sequential order
* @param v
* @return
*/
public
int
indexOf
(
int
v
)
{
return
Arrays
.
binarySearch
(
array
,
v
);
}
}
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