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
a17d36de
authored
Jan 28, 2022
by
Dustin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Minor cleanup
parent
1ff78292
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
47 deletions
library/core/src/main/java/com/google/android/exoplayer2/video/BitmapFactoryVideoRenderer.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/video/BitmapFactoryVideoRenderer.java
View file @
a17d36de
...
@@ -148,7 +148,10 @@ public class BitmapFactoryVideoRenderer extends BaseRenderer {
...
@@ -148,7 +148,10 @@ public class BitmapFactoryVideoRenderer extends BaseRenderer {
return
null
;
return
null
;
}
}
private
void
renderBitmap
(
final
Bitmap
bitmap
,
@NonNull
final
Surface
surface
)
{
private
void
renderBitmap
(
final
Bitmap
bitmap
,
@Nullable
final
Surface
surface
)
{
if
(
surface
==
null
)
{
return
;
}
//Log.d(TAG, "Drawing: " + bitmap.getWidth() + "x" + bitmap.getHeight());
//Log.d(TAG, "Drawing: " + bitmap.getWidth() + "x" + bitmap.getHeight());
final
Canvas
canvas
=
surface
.
lockCanvas
(
null
);
final
Canvas
canvas
=
surface
.
lockCanvas
(
null
);
...
@@ -243,13 +246,8 @@ public class BitmapFactoryVideoRenderer extends BaseRenderer {
...
@@ -243,13 +246,8 @@ public class BitmapFactoryVideoRenderer extends BaseRenderer {
if
(
sleep
())
{
if
(
sleep
())
{
continue
main
;
continue
main
;
}
}
if
(!
running
)
{
break
main
;
}
}
}
@Nullable
if
(
running
)
{
final
Surface
surface
=
BitmapFactoryVideoRenderer
.
this
.
surface
;
if
(
surface
!=
null
)
{
renderBitmap
(
bitmap
,
surface
);
renderBitmap
(
bitmap
,
surface
);
}
}
}
else
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
}
else
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java
View file @
a17d36de
...
@@ -57,6 +57,34 @@ public class AviExtractor implements Extractor {
...
@@ -57,6 +57,34 @@ public class AviExtractor implements Extractor {
}
}
}
}
static
int
checkAlign
(
final
ExtractorInput
input
,
PositionHolder
seekPosition
)
{
final
long
position
=
input
.
getPosition
();
if
((
position
&
1
)
==
1
)
{
seekPosition
.
position
=
position
+
1
;
return
RESULT_SEEK
;
}
return
RESULT_CONTINUE
;
}
static
ByteBuffer
allocate
(
int
bytes
)
{
final
byte
[]
buffer
=
new
byte
[
bytes
];
final
ByteBuffer
byteBuffer
=
ByteBuffer
.
wrap
(
buffer
);
byteBuffer
.
order
(
ByteOrder
.
LITTLE_ENDIAN
);
return
byteBuffer
;
}
@VisibleForTesting
static
int
getStreamId
(
int
chunkId
)
{
final
int
upperChar
=
chunkId
&
0xff
;
if
(
Character
.
isDigit
(
upperChar
))
{
final
int
lowerChar
=
(
chunkId
>>
8
)
&
0xff
;
if
(
Character
.
isDigit
(
upperChar
))
{
return
(
lowerChar
&
0xf
)
+
((
upperChar
&
0xf
)
*
10
);
}
}
return
-
1
;
}
static
final
String
TAG
=
"AviExtractor"
;
static
final
String
TAG
=
"AviExtractor"
;
@VisibleForTesting
@VisibleForTesting
static
final
int
PEEK_BYTES
=
28
;
static
final
int
PEEK_BYTES
=
28
;
...
@@ -87,8 +115,6 @@ public class AviExtractor implements Extractor {
...
@@ -87,8 +115,6 @@ public class AviExtractor implements Extractor {
static
final
int
JUNK
=
'J'
|
(
'U'
<<
8
)
|
(
'N'
<<
16
)
|
(
'K'
<<
24
);
static
final
int
JUNK
=
'J'
|
(
'U'
<<
8
)
|
(
'N'
<<
16
)
|
(
'K'
<<
24
);
static
final
int
REC_
=
'r'
|
(
'e'
<<
8
)
|
(
'c'
<<
16
)
|
(
' '
<<
24
);
static
final
int
REC_
=
'r'
|
(
'e'
<<
8
)
|
(
'c'
<<
16
)
|
(
' '
<<
24
);
static
final
long
SEEK_GAP
=
2_000_000L
;
//Time between seek points in micro seconds
@VisibleForTesting
@VisibleForTesting
int
state
;
int
state
;
@VisibleForTesting
@VisibleForTesting
...
@@ -112,7 +138,6 @@ public class AviExtractor implements Extractor {
...
@@ -112,7 +138,6 @@ public class AviExtractor implements Extractor {
/**
/**
*
*
* @param input
* @param bytes Must be at least 20
* @param bytes Must be at least 20
*/
*/
@Nullable
@Nullable
...
@@ -143,7 +168,7 @@ public class AviExtractor implements Extractor {
...
@@ -143,7 +168,7 @@ public class AviExtractor implements Extractor {
}
}
@Override
@Override
public
boolean
sniff
(
ExtractorInput
input
)
throws
IOException
{
public
boolean
sniff
(
@NonNull
ExtractorInput
input
)
throws
IOException
{
final
ByteBuffer
byteBuffer
=
getAviBuffer
(
input
,
PEEK_BYTES
);
final
ByteBuffer
byteBuffer
=
getAviBuffer
(
input
,
PEEK_BYTES
);
if
(
byteBuffer
==
null
)
{
if
(
byteBuffer
==
null
)
{
return
false
;
return
false
;
...
@@ -155,29 +180,7 @@ public class AviExtractor implements Extractor {
...
@@ -155,29 +180,7 @@ public class AviExtractor implements Extractor {
return
false
;
return
false
;
}
}
final
int
avih
=
byteBuffer
.
getInt
();
final
int
avih
=
byteBuffer
.
getInt
();
if
(
avih
!=
AviHeaderBox
.
AVIH
)
{
return
avih
==
AviHeaderBox
.
AVIH
;
return
false
;
}
return
true
;
}
static
ByteBuffer
allocate
(
int
bytes
)
{
final
byte
[]
buffer
=
new
byte
[
bytes
];
final
ByteBuffer
byteBuffer
=
ByteBuffer
.
wrap
(
buffer
);
byteBuffer
.
order
(
ByteOrder
.
LITTLE_ENDIAN
);
return
byteBuffer
;
}
@VisibleForTesting
static
int
getStreamId
(
int
chunkId
)
{
final
int
upperChar
=
chunkId
&
0xff
;
if
(
Character
.
isDigit
(
upperChar
))
{
final
int
lowerChar
=
(
chunkId
>>
8
)
&
0xff
;
if
(
Character
.
isDigit
(
upperChar
))
{
return
(
lowerChar
&
0xf
)
+
((
upperChar
&
0xf
)
*
10
);
}
}
return
-
1
;
}
}
@VisibleForTesting
@VisibleForTesting
...
@@ -206,7 +209,7 @@ public class AviExtractor implements Extractor {
...
@@ -206,7 +209,7 @@ public class AviExtractor implements Extractor {
}
}
@Override
@Override
public
void
init
(
ExtractorOutput
output
)
{
public
void
init
(
@NonNull
ExtractorOutput
output
)
{
this
.
state
=
STATE_READ_TRACKS
;
this
.
state
=
STATE_READ_TRACKS
;
this
.
output
=
output
;
this
.
output
=
output
;
}
}
...
@@ -379,9 +382,6 @@ public class AviExtractor implements Extractor {
...
@@ -379,9 +382,6 @@ public class AviExtractor implements Extractor {
/**
/**
* Reads the index and sets the keyFrames and creates the SeekMap
* Reads the index and sets the keyFrames and creates the SeekMap
* @param input
* @param remaining
* @throws IOException
*/
*/
void
readIdx1
(
ExtractorInput
input
,
int
remaining
)
throws
IOException
{
void
readIdx1
(
ExtractorInput
input
,
int
remaining
)
throws
IOException
{
final
AviTrack
videoTrack
=
getVideoTrack
();
final
AviTrack
videoTrack
=
getVideoTrack
();
...
@@ -478,15 +478,6 @@ public class AviExtractor implements Extractor {
...
@@ -478,15 +478,6 @@ public class AviExtractor implements Extractor {
return
null
;
return
null
;
}
}
int
checkAlign
(
final
ExtractorInput
input
,
PositionHolder
seekPosition
)
{
final
long
position
=
input
.
getPosition
();
if
((
position
&
1
)
==
1
)
{
seekPosition
.
position
=
position
+
1
;
return
RESULT_SEEK
;
}
return
RESULT_CONTINUE
;
}
int
readSamples
(
ExtractorInput
input
,
PositionHolder
seekPosition
)
throws
IOException
{
int
readSamples
(
ExtractorInput
input
,
PositionHolder
seekPosition
)
throws
IOException
{
if
(
chunkHandler
!=
null
)
{
if
(
chunkHandler
!=
null
)
{
if
(
chunkHandler
.
resume
(
input
))
{
if
(
chunkHandler
.
resume
(
input
))
{
...
...
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