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
4abd34d8
authored
May 09, 2023
by
tofunmi
Committed by
Tofunmi Adigun-Hameed
May 11, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Image transcoding: Add support for heic/heif image formats
PiperOrigin-RevId: 530578549
parent
8c6da05f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
library/effect/src/main/java/com/google/android/exoplayer2/effect/BitmapTextureManager.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/DefaultAssetLoaderFactory.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/BitmapTextureManager.java
View file @
4abd34d8
...
...
@@ -16,6 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
effect
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkState
;
import
static
java
.
lang
.
Math
.
round
;
import
android.graphics.Bitmap
;
...
...
@@ -25,6 +26,7 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.GlTextureInfo
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.VideoFrameProcessingException
;
import
java.util.Queue
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
...
@@ -37,6 +39,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* <p>Public methods in this class can be called from any thread.
*/
/* package */
final
class
BitmapTextureManager
implements
TextureManager
{
private
static
final
String
UNSUPPORTED_IMAGE_CONFIGURATION
=
"Unsupported Image Configuration: No more than 8 bits of precision should be used for each"
+
" RGB channel."
;
private
final
GlShaderProgram
shaderProgram
;
private
final
VideoFrameProcessingTaskExecutor
videoFrameProcessingTaskExecutor
;
// The queue holds all bitmaps with one or more frames pending to be sent downstream.
...
...
@@ -123,6 +128,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private
void
setupBitmap
(
Bitmap
bitmap
,
long
durationUs
,
long
offsetUs
,
float
frameRate
,
boolean
useHdr
)
throws
VideoFrameProcessingException
{
if
(
Util
.
SDK_INT
>=
26
)
{
checkState
(
!
bitmap
.
getConfig
().
equals
(
Bitmap
.
Config
.
RGBA_F16
),
UNSUPPORTED_IMAGE_CONFIGURATION
);
}
if
(
Util
.
SDK_INT
>=
33
)
{
checkState
(
!
bitmap
.
getConfig
().
equals
(
Bitmap
.
Config
.
RGBA_1010102
),
UNSUPPORTED_IMAGE_CONFIGURATION
);
}
this
.
useHdr
=
useHdr
;
int
framesToAdd
=
round
(
frameRate
*
(
durationUs
/
(
float
)
C
.
MICROS_PER_SECOND
));
double
frameDurationUs
=
C
.
MICROS_PER_SECOND
/
frameRate
;
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/DefaultAssetLoaderFactory.java
View file @
4abd34d8
...
...
@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.MediaItem;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.util.Clock
;
import
com.google.common.collect.ImmutableList
;
import
java.util.Locale
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
/** The default {@link AssetLoader.Factory} implementation. */
...
...
@@ -112,13 +113,14 @@ public final class DefaultAssetLoaderFactory implements AssetLoader.Factory {
if
(
localConfiguration
==
null
)
{
return
false
;
}
ImmutableList
<
String
>
supportedImageTypes
=
ImmutableList
.
of
(
".png"
,
".webp"
,
".jpg"
,
".jpeg"
);
ImmutableList
<
String
>
supportedImageTypes
=
ImmutableList
.
of
(
".png"
,
".webp"
,
".jpg"
,
".jpeg"
,
".heic"
,
".heif"
);
String
uriPath
=
checkNotNull
(
localConfiguration
.
uri
.
getPath
());
int
fileExtensionStart
=
uriPath
.
lastIndexOf
(
"."
);
if
(
fileExtensionStart
<
0
)
{
return
false
;
}
String
extension
=
uriPath
.
substring
(
fileExtensionStart
);
String
extension
=
uriPath
.
substring
(
fileExtensionStart
)
.
toLowerCase
(
Locale
.
ENGLISH
)
;
return
supportedImageTypes
.
contains
(
extension
);
}
}
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