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
9e340291
authored
Feb 18, 2018
by
Drew Hill
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
mkv h263 CR changes
parent
25c241e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
42 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
View file @
9e340291
...
@@ -1713,26 +1713,9 @@ public final class MatroskaExtractor implements Extractor {
...
@@ -1713,26 +1713,9 @@ public final class MatroskaExtractor implements Extractor {
nalUnitLengthFieldLength
=
hevcConfig
.
nalUnitLengthFieldLength
;
nalUnitLengthFieldLength
=
hevcConfig
.
nalUnitLengthFieldLength
;
break
;
break
;
case
CODEC_ID_FOURCC:
case
CODEC_ID_FOURCC:
initializationData
=
null
;
Pair
<
String
,
List
<
byte
[]>>
pair
=
parseFourCcPrivate
(
new
ParsableByteArray
(
codecPrivate
));
Pair
<
Integer
,
List
<
byte
[]>>
pair
=
parseFourCcVc1Private
(
new
ParsableByteArray
(
codecPrivate
));
mimeType
=
pair
.
first
;
if
(
pair
!=
null
)
{
initializationData
=
pair
.
second
;
initializationData
=
pair
.
second
;
switch
(
pair
.
first
)
{
case
FOURCC_COMPRESSION_VC1:
mimeType
=
MimeTypes
.
VIDEO_VC1
;
break
;
case
FOURCC_COMPRESSION_DIVX:
mimeType
=
MimeTypes
.
VIDEO_H263
;
break
;
default
:
Log
.
w
(
TAG
,
"Unknown FourCC. Setting mimeType to "
+
MimeTypes
.
VIDEO_UNKNOWN
);
mimeType
=
MimeTypes
.
VIDEO_UNKNOWN
;
break
;
}
}
else
{
Log
.
w
(
TAG
,
"Unsupported FourCC. Setting mimeType to "
+
MimeTypes
.
VIDEO_UNKNOWN
);
mimeType
=
MimeTypes
.
VIDEO_UNKNOWN
;
}
break
;
break
;
case
CODEC_ID_THEORA:
case
CODEC_ID_THEORA:
// TODO: This can be set to the real mimeType if/when we work out what initializationData
// TODO: This can be set to the real mimeType if/when we work out what initializationData
...
@@ -1947,41 +1930,42 @@ public final class MatroskaExtractor implements Extractor {
...
@@ -1947,41 +1930,42 @@ public final class MatroskaExtractor implements Extractor {
/**
/**
* Builds initialization data for a {@link Format} from FourCC codec private data.
* Builds initialization data for a {@link Format} from FourCC codec private data.
* <p>
* <p>
* VC1
is the only supported compression type
.
* VC1
and H263 are the only supported compression types
.
*
*
* @return The initialization data for the {@link Format}, or null if the compression type is
* @return A pair object with the first object being the codec mime type
* not VC1.
* and the second object the initialization data for the {@link Format},
* or null if the compression type is not VC1.
* @throws ParserException If the initialization data could not be built.
* @throws ParserException If the initialization data could not be built.
*/
*/
private
static
Pair
<
Integer
,
List
<
byte
[]>>
parseFourCcVc1
Private
(
ParsableByteArray
buffer
)
private
static
Pair
<
String
,
List
<
byte
[]>>
parseFourCc
Private
(
ParsableByteArray
buffer
)
throws
ParserException
{
throws
ParserException
{
try
{
try
{
buffer
.
skipBytes
(
16
);
// size(4), width(4), height(4), planes(2), bitcount(2).
buffer
.
skipBytes
(
16
);
// size(4), width(4), height(4), planes(2), bitcount(2).
long
compression
=
buffer
.
readLittleEndianUnsignedInt
();
long
compression
=
buffer
.
readLittleEndianUnsignedInt
();
if
(
compression
==
FOURCC_COMPRESSION_DIVX
)
{
if
(
compression
==
FOURCC_COMPRESSION_DIVX
)
{
return
new
Pair
(
FOURCC_COMPRESSION_DIVX
,
null
);
return
new
Pair
<>(
MimeTypes
.
VIDEO_H263
,
null
);
}
if
(
compression
!=
FOURCC_COMPRESSION_VC1
)
{
return
null
;
}
}
else
if
(
compression
==
FOURCC_COMPRESSION_VC1
)
{
// Search for the initialization data from the end of the BITMAPINFOHEADER. The last 20
// Search for the initialization data from the end of the BITMAPINFOHEADER. The last 20
// bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
// bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
int
startOffset
=
buffer
.
getPosition
()
+
20
;
int
startOffset
=
buffer
.
getPosition
()
+
20
;
byte
[]
bufferData
=
buffer
.
data
;
byte
[]
bufferData
=
buffer
.
data
;
for
(
int
offset
=
startOffset
;
offset
<
bufferData
.
length
-
4
;
offset
++)
{
for
(
int
offset
=
startOffset
;
offset
<
bufferData
.
length
-
4
;
offset
++)
{
if
(
bufferData
[
offset
]
==
0x00
&&
bufferData
[
offset
+
1
]
==
0x00
if
(
bufferData
[
offset
]
==
0x00
&&
bufferData
[
offset
+
1
]
==
0x00
&&
bufferData
[
offset
+
2
]
==
0x01
&&
bufferData
[
offset
+
3
]
==
0x0F
)
{
&&
bufferData
[
offset
+
2
]
==
0x01
&&
bufferData
[
offset
+
3
]
==
0x0F
)
{
// We've found the initialization data.
// We've found the initialization data.
byte
[]
initializationData
=
Arrays
.
copyOfRange
(
bufferData
,
offset
,
bufferData
.
length
);
byte
[]
initializationData
=
Arrays
.
copyOfRange
(
bufferData
,
offset
,
bufferData
.
length
);
return
new
Pair
(
FOURCC_COMPRESSION_VC1
,
Collections
.
singletonList
(
initializationData
));
return
new
Pair
<>(
MimeTypes
.
VIDEO_VC1
,
Collections
.
singletonList
(
initializationData
));
}
}
}
throw
new
ParserException
(
"Failed to find FourCC VC1 initialization data"
);
}
}
throw
new
ParserException
(
"Failed to find FourCC VC1 initialization data"
);
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
throw
new
ParserException
(
"Error parsing FourCC
VC1 codec private
"
);
throw
new
ParserException
(
"Error parsing FourCC
private data
"
);
}
}
Log
.
w
(
TAG
,
"Unknown FourCC. Setting mimeType to "
+
MimeTypes
.
VIDEO_UNKNOWN
);
return
new
Pair
<>(
MimeTypes
.
VIDEO_UNKNOWN
,
null
);
}
}
/**
/**
...
...
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