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
e2a6775e
authored
Mar 10, 2020
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Merge pull request #6999 from xufuji456:dev-v2
PiperOrigin-RevId: 298544278
parent
c3f9f0e5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
23 deletions
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegLibrary.java
extensions/ffmpeg/src/main/jni/Android.mk
extensions/ffmpeg/src/main/jni/build_ffmpeg.sh
extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegLibrary.java
View file @
e2a6775e
...
...
@@ -33,7 +33,7 @@ public final class FfmpegLibrary {
private
static
final
String
TAG
=
"FfmpegLibrary"
;
private
static
final
LibraryLoader
LOADER
=
new
LibraryLoader
(
"avutil"
,
"
avresample"
,
"
swresample"
,
"avcodec"
,
"ffmpeg"
);
new
LibraryLoader
(
"avutil"
,
"swresample"
,
"avcodec"
,
"ffmpeg"
);
private
FfmpegLibrary
()
{}
...
...
extensions/ffmpeg/src/main/jni/Android.mk
View file @
e2a6775e
...
...
@@ -22,11 +22,6 @@ LOCAL_SRC_FILES := ffmpeg/android-libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libavresample
LOCAL_SRC_FILES := ffmpeg/android-libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libswresample
LOCAL_SRC_FILES := ffmpeg/android-libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
...
...
@@ -40,6 +35,6 @@ include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := ffmpeg_jni.cc
LOCAL_C_INCLUDES := ffmpeg
LOCAL_SHARED_LIBRARIES := libavcodec lib
avresample lib
swresample libavutil
LOCAL_SHARED_LIBRARIES := libavcodec libswresample libavutil
LOCAL_LDLIBS := -Lffmpeg/android-libs/$(TARGET_ARCH_ABI) -llog
include $(BUILD_SHARED_LIBRARY)
extensions/ffmpeg/src/main/jni/build_ffmpeg.sh
View file @
e2a6775e
...
...
@@ -32,7 +32,7 @@ COMMON_OPTIONS="
--disable-postproc
--disable-avfilter
--disable-symver
--
en
able-avresample
--
dis
able-avresample
--enable-swresample
"
TOOLCHAIN_PREFIX
=
"
${
NDK_PATH
}
/toolchains/llvm/prebuilt/
${
HOST_PLATFORM
}
/bin"
...
...
extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc
View file @
e2a6775e
...
...
@@ -26,10 +26,10 @@ extern "C" {
#include <stdint.h>
#endif
#include <libavcodec/avcodec.h>
#include <libavresample/avresample.h>
#include <libavutil/channel_layout.h>
#include <libavutil/error.h>
#include <libavutil/opt.h>
#include <libswresample/swresample.h>
}
#define LOG_TAG "ffmpeg_jni"
...
...
@@ -289,11 +289,11 @@ int decodePacket(AVCodecContext *context, AVPacket *packet,
int
sampleCount
=
frame
->
nb_samples
;
int
dataSize
=
av_samples_get_buffer_size
(
NULL
,
channelCount
,
sampleCount
,
sampleFormat
,
1
);
AVAudioResample
Context
*
resampleContext
;
Swr
Context
*
resampleContext
;
if
(
context
->
opaque
)
{
resampleContext
=
(
AVAudioResampleContext
*
)
context
->
opaque
;
resampleContext
=
(
SwrContext
*
)
context
->
opaque
;
}
else
{
resampleContext
=
avresample_alloc_context
();
resampleContext
=
swr_alloc
();
av_opt_set_int
(
resampleContext
,
"in_channel_layout"
,
channelLayout
,
0
);
av_opt_set_int
(
resampleContext
,
"out_channel_layout"
,
channelLayout
,
0
);
av_opt_set_int
(
resampleContext
,
"in_sample_rate"
,
sampleRate
,
0
);
...
...
@@ -302,9 +302,9 @@ int decodePacket(AVCodecContext *context, AVPacket *packet,
// The output format is always the requested format.
av_opt_set_int
(
resampleContext
,
"out_sample_fmt"
,
context
->
request_sample_fmt
,
0
);
result
=
avresample_open
(
resampleContext
);
result
=
swr_init
(
resampleContext
);
if
(
result
<
0
)
{
logError
(
"
avresample_open
"
,
result
);
logError
(
"
swr_init
"
,
result
);
av_frame_free
(
&
frame
);
return
-
1
;
}
...
...
@@ -312,7 +312,7 @@ int decodePacket(AVCodecContext *context, AVPacket *packet,
}
int
inSampleSize
=
av_get_bytes_per_sample
(
sampleFormat
);
int
outSampleSize
=
av_get_bytes_per_sample
(
context
->
request_sample_fmt
);
int
outSamples
=
avresample
_get_out_samples
(
resampleContext
,
sampleCount
);
int
outSamples
=
swr
_get_out_samples
(
resampleContext
,
sampleCount
);
int
bufferOutSize
=
outSampleSize
*
channelCount
*
outSamples
;
if
(
outSize
+
bufferOutSize
>
outputSize
)
{
LOGE
(
"Output buffer size (%d) too small for output data (%d)."
,
...
...
@@ -320,15 +320,14 @@ int decodePacket(AVCodecContext *context, AVPacket *packet,
av_frame_free
(
&
frame
);
return
-
1
;
}
result
=
avresample_convert
(
resampleContext
,
&
outputBuffer
,
bufferOutSize
,
outSamples
,
frame
->
data
,
frame
->
linesize
[
0
],
sampleCount
);
result
=
swr_convert
(
resampleContext
,
&
outputBuffer
,
bufferOutSize
,
(
const
uint8_t
**
)
frame
->
data
,
frame
->
nb_samples
);
av_frame_free
(
&
frame
);
if
(
result
<
0
)
{
logError
(
"
avresample
_convert"
,
result
);
logError
(
"
swr
_convert"
,
result
);
return
result
;
}
int
available
=
avresample_available
(
resampleContext
);
int
available
=
swr_get_out_samples
(
resampleContext
,
0
);
if
(
available
!=
0
)
{
LOGE
(
"Expected no samples remaining after resampling, but found %d."
,
available
);
...
...
@@ -351,9 +350,9 @@ void releaseContext(AVCodecContext *context) {
if
(
!
context
)
{
return
;
}
AVAudioResampleContext
*
resample
Context
;
if
((
resampleContext
=
(
AVAudioResampleContext
*
)
context
->
opaque
))
{
avresample_free
(
&
resample
Context
);
SwrContext
*
swr
Context
;
if
((
swrContext
=
(
SwrContext
*
)
context
->
opaque
))
{
swr_free
(
&
swr
Context
);
context
->
opaque
=
NULL
;
}
avcodec_free_context
(
&
context
);
...
...
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