Bug 1035059 - Fix releasing of libav frames; r=edwin
authorAnthony Jones <ajones@mozilla.com>
Fri, 11 Jul 2014 18:43:57 +1200
changeset 214335 d95cd8921f2ce54eb7e989b9502d1d8e4ccdd0bc
parent 214334 90c8436f8851432476c5c51b884f88c827e8de44
child 214336 a9ad61be640668d2a610c861a5184e6cf658e15c
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1035059
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1035059 - Fix releasing of libav frames; r=edwin
content/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp
content/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp
--- a/content/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp
+++ b/content/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp
@@ -80,17 +80,17 @@ FFmpegDataDecoder<LIBAV_VER>::Init()
 
   // FFmpeg takes this as a suggestion for what format to use for audio samples.
   mCodecContext.request_sample_fmt = AV_SAMPLE_FMT_FLT;
 
   // FFmpeg will call back to this to negotiate a video pixel format.
   mCodecContext.get_format = ChoosePixelFormat;
 
   mCodecContext.thread_count = PR_GetNumberOfProcessors();
-  mCodecContext.thread_type = FF_THREAD_FRAME;
+  mCodecContext.thread_type = FF_THREAD_SLICE | FF_THREAD_FRAME;
   mCodecContext.thread_safe_callbacks = false;
 
   mCodecContext.extradata = mExtraData.begin();
   mCodecContext.extradata_size = mExtraData.length();
 
   AVDictionary* opts = nullptr;
   if (avcodec_open2(&mCodecContext, codec, &opts) < 0) {
     NS_WARNING("Couldn't initialise ffmpeg decoder");
--- a/content/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp
+++ b/content/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp
@@ -132,17 +132,21 @@ FFmpegH264Decoder<LIBAV_VER>::AllocateBu
     return avcodec_default_get_buffer(aCodecContext, aFrame);
   }
 }
 
 /* static */ void
 FFmpegH264Decoder<LIBAV_VER>::ReleaseBufferCb(AVCodecContext* aCodecContext,
                                               AVFrame* aFrame)
 {
-  reinterpret_cast<Image*>(aFrame->opaque)->Release();
+  Image* image = reinterpret_cast<Image*>(aFrame->opaque);
+  avcodec_default_release_buffer(aCodecContext, aFrame);
+  if (image) {
+    image->Release();
+  }
 }
 
 int
 FFmpegH264Decoder<LIBAV_VER>::AllocateYUV420PVideoBuffer(
   AVCodecContext* aCodecContext, AVFrame* aFrame)
 {
   // Older versions of ffmpeg require that edges be allocated* around* the
   // actual image.