bug 1476231 link ffmpeg real DFT functions r?jya draft
authorKarl Tomlinson <karlt+@karlt.net>
Sat, 14 Jul 2018 11:57:45 +1200
changeset 825590 ca35da82171facdf606443f6a0da7c0da000df36
parent 825589 2472986e87708cef8b43cd598175c913914abe85
child 825591 9645063a4bd139de0e149bcc346bce437c72bf33
push id118144
push userktomlinson@mozilla.com
push dateThu, 02 Aug 2018 02:57:58 +0000
reviewersjya
bugs1476231
milestone63.0a1
bug 1476231 link ffmpeg real DFT functions r?jya MozReview-Commit-ID: 1K5tta51rBB
dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
dom/media/platforms/ffmpeg/FFmpegRDFTTypes.h
--- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
@@ -133,16 +133,19 @@ FFmpegLibWrapper::Link()
   AV_FUNC(avcodec_register_all, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_init_packet, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_parser_init, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_parser_close, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_parser_parse2, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(avcodec_alloc_frame, (AV_FUNC_53 | AV_FUNC_54))
   AV_FUNC(avcodec_get_frame_defaults, (AV_FUNC_53 | AV_FUNC_54))
   AV_FUNC(avcodec_free_frame, AV_FUNC_54)
+  AV_FUNC_OPTION(av_rdft_init, AV_FUNC_AVCODEC_ALL)
+  AV_FUNC_OPTION(av_rdft_calc, AV_FUNC_AVCODEC_ALL)
+  AV_FUNC_OPTION(av_rdft_end, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL)
   AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL)
   AV_FUNC(av_freep, AV_FUNC_AVUTIL_ALL)
   AV_FUNC(av_frame_alloc, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
   AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
   AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
   AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL)
 #undef AV_FUNC
--- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __FFmpegLibWrapper_h__
 #define __FFmpegLibWrapper_h__
 
+#include "FFmpegRDFTTypes.h" // for AvRdftInitFn, etc.
 #include "mozilla/Attributes.h"
 #include "mozilla/Types.h"
 
 struct AVCodec;
 struct AVCodecContext;
 struct AVFrame;
 struct AVPacket;
 struct AVDictionary;
@@ -70,16 +71,21 @@ struct MOZ_ONLY_USED_TO_AVOID_STATIC_CON
   int (*av_parser_parse2)(AVCodecParserContext* s, AVCodecContext* avctx, uint8_t** poutbuf, int* poutbuf_size, const uint8_t* buf, int buf_size, int64_t pts, int64_t dts, int64_t pos);
 
   // only used in libavcodec <= 54
   AVFrame* (*avcodec_alloc_frame)();
   void (*avcodec_get_frame_defaults)(AVFrame* pic);
   // libavcodec v54 only
   void (*avcodec_free_frame)(AVFrame** frame);
 
+  // libavcodec optional
+  AvRdftInitFn av_rdft_init;
+  AvRdftCalcFn av_rdft_calc;
+  AvRdftEndFn av_rdft_end;
+
   // libavutil
   void (*av_log_set_level)(int level);
   void*	(*av_malloc)(size_t size);
   void (*av_freep)(void *ptr);
 
   // libavutil v55 and later only
   AVFrame* (*av_frame_alloc)();
   void (*av_frame_free)(AVFrame** frame);
new file mode 100644
--- /dev/null
+++ b/dom/media/platforms/ffmpeg/FFmpegRDFTTypes.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+#ifndef FFmpegRDFTTypes_h
+#define FFmpegRDFTTypes_h
+
+struct RDFTContext;
+
+typedef float FFTSample;
+
+enum RDFTransformType {
+    DFT_R2C,
+    IDFT_C2R,
+    IDFT_R2C,
+    DFT_C2R,
+};
+
+extern "C" {
+
+  typedef RDFTContext* (*AvRdftInitFn)(int nbits, enum RDFTransformType trans);
+  typedef void (*AvRdftCalcFn)(RDFTContext *s, FFTSample *data);
+  typedef void (*AvRdftEndFn)(RDFTContext *s);
+
+}
+
+#endif // FFmpegRDFTTypes_h