summaryrefslogtreecommitdiffstats
path: root/dom/media/platforms
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-10-02 09:39:56 +0200
committerGitHub <noreply@github.com>2018-10-02 09:39:56 +0200
commit26975ccf5609c787f088e462a72b24bd1a555126 (patch)
tree1885515de3fef357187a8f471b7b82a36cf82c29 /dom/media/platforms
parent69d83c8fbe47b89d1d14f75ee99e638cbfb5dc31 (diff)
parentc0d9931cffdf42cdd51c6bf9e44e2a8281a6254f (diff)
downloadUXP-26975ccf5609c787f088e462a72b24bd1a555126.tar
UXP-26975ccf5609c787f088e462a72b24bd1a555126.tar.gz
UXP-26975ccf5609c787f088e462a72b24bd1a555126.tar.lz
UXP-26975ccf5609c787f088e462a72b24bd1a555126.tar.xz
UXP-26975ccf5609c787f088e462a72b24bd1a555126.zip
Merge pull request #808 from trav90/media-work
[ffmpeg] Always allocate memory to pass extradata
Diffstat (limited to 'dom/media/platforms')
-rw-r--r--dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
index 8cb5c8578..8655ce25f 100644
--- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
@@ -69,12 +69,21 @@ FFmpegDataDecoder<LIBAV_VER>::InitDecoder()
mCodecContext->extradata_size = mExtraData->Length();
// FFmpeg may use SIMD instructions to access the data which reads the
// data in 32 bytes block. Must ensure we have enough data to read.
+ uint32_t padding_size =
#if LIBAVCODEC_VERSION_MAJOR >= 58
- mExtraData->AppendElements(AV_INPUT_BUFFER_PADDING_SIZE);
+ AV_INPUT_BUFFER_PADDING_SIZE;
#else
- mExtraData->AppendElements(FF_INPUT_BUFFER_PADDING_SIZE);
+ FF_INPUT_BUFFER_PADDING_SIZE;
#endif
- mCodecContext->extradata = mExtraData->Elements();
+ mCodecContext->extradata = static_cast<uint8_t*>(
+ mLib->av_malloc(mExtraData->Length() + padding_size));
+ if (!mCodecContext->extradata) {
+ return MediaResult(NS_ERROR_OUT_OF_MEMORY,
+ RESULT_DETAIL("Couldn't init ffmpeg extradata"));
+ }
+ memcpy(mCodecContext->extradata,
+ mExtraData->Elements(),
+ mExtraData->Length());
} else {
mCodecContext->extradata_size = 0;
}
@@ -165,6 +174,9 @@ FFmpegDataDecoder<LIBAV_VER>::ProcessShutdown()
StaticMutexAutoLock mon(sMonitor);
if (mCodecContext) {
+ if (mCodecContext->extradata) {
+ mLib->av_freep(&mCodecContext->extradata);
+ }
mLib->avcodec_close(mCodecContext);
mLib->av_freep(&mCodecContext);
#if LIBAVCODEC_VERSION_MAJOR >= 55